Skip to content

Commit

Permalink
osbuild: add test for NewMkswapStage()
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 authored and ondrejbudai committed Nov 28, 2024
1 parent ed82b67 commit f4715c3
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pkg/osbuild/mkswap_stage_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package osbuild

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
)

var expectedJSON = `{
"type": "org.osbuild.mkswap",
"options": {
"uuid": "8a1fc521-02a0-4917-92a9-90a44d7e6503",
"label": "some-label"
},
"devices": {
"root": {
"type": "org.osbuild.loopback"
}
}
}`

func TestNewMkswapStage(t *testing.T) {
devices := make(map[string]Device)
devices["root"] = Device{
Type: "org.osbuild.loopback",
}

options := MkswapStageOptions{
UUID: "8a1fc521-02a0-4917-92a9-90a44d7e6503",
Label: "some-label",
}
stage := NewMkswapStage(&options, devices)
b, err := json.MarshalIndent(stage, "", " ")
assert.NoError(t, err)
assert.Equal(t, expectedJSON, string(b))
}

0 comments on commit f4715c3

Please sign in to comment.