Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
marccampbell committed Nov 8, 2019
1 parent dd869f7 commit a5a1c50
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions pkg/analyze/distribution_test.go
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)
})
}
}

0 comments on commit a5a1c50

Please sign in to comment.