Skip to content

Commit

Permalink
test: extend unit-tests for config contract parsing
Browse files Browse the repository at this point in the history
Test that `v0.8.` is not a typo.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
  • Loading branch information
AlekSi authored and talos-bot committed Apr 12, 2021
1 parent d24df8f commit 7b0ac46
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions pkg/machinery/config/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,24 @@ func TestContractGreater(t *testing.T) {
}

func TestContractParseVersion(t *testing.T) {
contract, err := config.ParseContractFromVersion("v0.8")
assert.NoError(t, err)
assert.Equal(t, config.TalosVersion0_8, contract)

contract, err = config.ParseContractFromVersion("v0.8.1")
assert.NoError(t, err)
assert.Equal(t, config.TalosVersion0_8, contract)

contract, err = config.ParseContractFromVersion("v0.88")
assert.NoError(t, err)
assert.NotEqual(t, config.TalosVersion0_8, contract)

contract, err = config.ParseContractFromVersion("v0.8.3-alpha.4")
assert.NoError(t, err)
assert.Equal(t, config.TalosVersion0_8, contract)
t.Parallel()

for v, expected := range map[string]*config.VersionContract{
"v0.8": config.TalosVersion0_8,
"v0.8.": config.TalosVersion0_8,
"v0.8.1": config.TalosVersion0_8,
"v0.88": {0, 88},
"v0.8.3-alpha.4": config.TalosVersion0_8,
} {
v, expected := v, expected
t.Run(v, func(t *testing.T) {
t.Parallel()

actual, err := config.ParseContractFromVersion(v)
assert.NoError(t, err)
assert.Equal(t, expected, actual)
})
}
}

func TestContractCurrent(t *testing.T) {
Expand Down

0 comments on commit 7b0ac46

Please sign in to comment.