Skip to content

Commit

Permalink
add tests for isAnExcludedAsset
Browse files Browse the repository at this point in the history
  • Loading branch information
Anubhav Aeron committed Sep 19, 2022
1 parent 20d557d commit 2e6aff6
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions admiral/pkg/clusters/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,5 +461,46 @@ func TestRoutingPolicyHandler(t *testing.T) {
handler.Updated(ctx, routingPolicyFoo)
assert.Nil(t, registry.AdmiralCache.RoutingPolicyFilterCache.Get("bar4stage"))
assert.Nil(t, registry.AdmiralCache.RoutingPolicyFilterCache.Get("bar3stage"))
}

func TestIsAnExcludedAsset(t *testing.T) {
testCases := []struct {
name string
assetName string
excludedAssetList []string
expectedResult bool
}{
{
name: "Given an asset is in the exclude list, " +
"When isAnExcludedAsset is called, " +
"Then, it should return true",
assetName: "excluded-asset1",
excludedAssetList: []string{"excluded-asset1"},
expectedResult: true,
},
{
name: "Given an asset is NOT in the exclude list, " +
"When isAnExcludedAsset is called, " +
"Then, it should return false",
assetName: "not-excluded-asset1",
excludedAssetList: []string{"excluded-asset1"},
expectedResult: false,
},
{
name: "Given an asset in the exclude list, " +
"When the asset name closely matches an excluded asset, " +
"And is different by one character, " +
"Then, it should return false",
assetName: "e1",
excludedAssetList: []string{"e2"},
expectedResult: false,
},
}

for _, c := range testCases {
result := isAnExcludedAsset(c.assetName, c.excludedAssetList)
if result != c.expectedResult {
t.Fatalf("expected: %v, got: %v", c.expectedResult, result)
}
}
}

0 comments on commit 2e6aff6

Please sign in to comment.