-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd869f7
commit a5a1c50
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package analyzer | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_compareDistributionConditionalToActual(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
conditional string | ||
input providers | ||
expected bool | ||
}{ | ||
{ | ||
name: "== microk8s when microk8s is found", | ||
conditional: "== microk8s", | ||
input: providers{ | ||
microk8s: true, | ||
}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "!= microk8s when microk8s is found", | ||
conditional: "!= microk8s", | ||
input: providers{ | ||
microk8s: true, | ||
}, | ||
expected: false, | ||
}, | ||
{ | ||
name: "!== eks when gke is found", | ||
conditional: "!== eks", | ||
input: providers{ | ||
gke: true, | ||
}, | ||
expected: true, | ||
}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
req := require.New(t) | ||
|
||
actual, err := compareDistributionConditionalToActual(test.conditional, test.input) | ||
req.NoError(err) | ||
|
||
assert.Equal(t, test.expected, actual) | ||
}) | ||
} | ||
|
||
} | ||
|
||
func Test_mustNormalizeDistributionName(t *testing.T) { | ||
tests := []struct { | ||
raw string | ||
expected Provider | ||
}{ | ||
{ | ||
raw: "microk8s", | ||
expected: microk8s, | ||
}, | ||
{ | ||
raw: "MICROK8S", | ||
expected: microk8s, | ||
}, | ||
{ | ||
raw: " microk8s ", | ||
expected: microk8s, | ||
}, | ||
{ | ||
raw: "Docker-Desktop", | ||
expected: dockerDesktop, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.raw, func(t *testing.T) { | ||
actual := mustNormalizeDistributionName(test.raw) | ||
|
||
assert.Equal(t, test.expected, actual) | ||
}) | ||
} | ||
} |