Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Emmanuel Jacquier <[email protected]>
  • Loading branch information
pierre-emmanuelJ committed Jul 23, 2024
1 parent 33cb46b commit eeccc70
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package utils

import (
"testing"

v3 "github.com/exoscale/egoscale/v3"
"github.com/stretchr/testify/assert"
)

func TestParseInstanceType(t *testing.T) {
testCases := []struct {
instanceType string
expectedFamily v3.InstanceTypeFamily
expectedSize v3.InstanceTypeSize
}{
{"standard.large", v3.InstanceTypeFamily("standard"), v3.InstanceTypeSize("large")},
{"gpu2.mega", v3.InstanceTypeFamily("gpu2"), v3.InstanceTypeSize("mega")},
{"colossus", v3.InstanceTypeFamily("standard"), v3.InstanceTypeSize("colossus")},
{"", v3.InstanceTypeFamily("standard"), v3.InstanceTypeSize("")},
{"invalid-format", v3.InstanceTypeFamily("standard"), v3.InstanceTypeSize("invalid-format")},
}

for _, tc := range testCases {
t.Run(tc.instanceType, func(t *testing.T) {
result := ParseInstanceType(tc.instanceType)
assert.Equal(t, tc.expectedFamily, result.Family)
assert.Equal(t, tc.expectedSize, result.Size)
})
}
}

0 comments on commit eeccc70

Please sign in to comment.