internal/blueprint: introduce new test for parsing blueprints

Test case like this was completely missing. A similar one is present in
the Weldr package, but this one is specific to testing blueprints and
thus easier to understand and extend.
This commit is contained in:
Martin Sehnoutka 2021-10-18 13:34:14 +02:00 committed by Ondřej Budai
parent 7d6dadb598
commit f2f078acd6

View file

@ -3,10 +3,34 @@ package blueprint
import (
"testing"
"github.com/BurntSushi/toml"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestBlueprintParse(t *testing.T) {
blueprint := `
name = "test"
description = "Test"
version = "0.0.0"
[[packages]]
name = "httpd"
version = "2.4.*"
[[customizations.filesystem]]
mountpoint = "/var"
size = 2147483648
`
var bp Blueprint
err := toml.Unmarshal([]byte(blueprint), &bp)
require.Nil(t, err)
assert.Equal(t, bp.Name, "test")
assert.Equal(t, "/var", bp.Customizations.Filesystem[0].Mountpoint)
assert.Equal(t, uint64(2147483648), bp.Customizations.Filesystem[0].MinSize)
}
func TestDeepCopy(t *testing.T) {
bpOrig := Blueprint{
Name: "deepcopy-test",