tests: Add a test for freezing a blueprint with globs
This is currently failing (fixed in the next commit). It tests to make sure that a blueprint with package name globs can be frozen. The resulting blueprint should replace the glob entries with the expanded list of packages.
This commit is contained in:
parent
73ab18a501
commit
c7bc25cead
1 changed files with 40 additions and 0 deletions
|
|
@ -1101,6 +1101,46 @@ func TestBlueprintFreezeV0(t *testing.T) {
|
|||
require.NotEqual(t, "*", frozen.Blueprints[0].Blueprint.Modules[0].Version, "Wrong version in frozen blueprint module")
|
||||
}
|
||||
|
||||
func TestBlueprintFreezeGlobsV0(t *testing.T) {
|
||||
// Test needs real packages, skip it for unit testing
|
||||
if testState.unitTest {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
bp := `{
|
||||
"name": "test-freeze-blueprint-glob-v0",
|
||||
"description": "TestBlueprintFreezeGlobsV0",
|
||||
"version": "0.0.1",
|
||||
"packages": [{"name": "tmux", "version": "?.*"},
|
||||
{"name": "openssh-*", "version": "*"}]
|
||||
}`
|
||||
|
||||
// Push a blueprint
|
||||
resp, err := PostJSONBlueprintV0(testState.socket, bp)
|
||||
require.NoError(t, err, "POST blueprint failed with a client error")
|
||||
require.True(t, resp.Status, "POST blueprint failed: %#v", resp)
|
||||
|
||||
// Freeze the blueprint
|
||||
frozen, api, err := FreezeBlueprintV0(testState.socket, "test-freeze-blueprint-glob-v0")
|
||||
require.NoError(t, err, "Freeze blueprint failed with a client error")
|
||||
require.Nil(t, api, "FreezeBlueprint failed: %#v", api)
|
||||
require.Greater(t, len(frozen.Blueprints), 0, "No frozen blueprints returned")
|
||||
require.Greater(t, len(frozen.Blueprints[0].Blueprint.Packages), 0, "No frozen packages returned")
|
||||
|
||||
var names []string
|
||||
for _, p := range frozen.Blueprints[0].Blueprint.Packages {
|
||||
assert.NotContains(t, p.Version, "*")
|
||||
assert.NotContains(t, p.Version, "?")
|
||||
names = append(names, p.Name)
|
||||
}
|
||||
sort.Strings(names)
|
||||
t.Log(names)
|
||||
assert.True(t, common.IsStringInSortedSlice(names, "openssh-clients"))
|
||||
assert.True(t, common.IsStringInSortedSlice(names, "openssh-server"))
|
||||
assert.True(t, common.IsStringInSortedSlice(names, "tmux"))
|
||||
|
||||
}
|
||||
|
||||
// freeze a non-existent blueprint
|
||||
func TestNonBlueprintFreezeV0(t *testing.T) {
|
||||
resp, api, err := FreezeBlueprintV0(testState.socket, "test-freeze-non-blueprint-v0")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue