forked from osbuild/images
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
osbuild: add test for NewMkswapStage()
- Loading branch information
1 parent
ed82b67
commit f4715c3
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |