From 5e97dcf2b3fb93506fd2ec6121b3744a5f08bc5d Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Wed, 30 Jun 2021 12:20:36 +0200 Subject: [PATCH] osbuild2: add missing JSON unmarshaling test for `org.osbuild.dracut` stage The `org.osbuild.dracut` stage was previously not tested for JSON unmarshalling. Add the missing test case and extend Stage's `UnmarshalJSON()` method. Signed-off-by: Tomas Hozza --- internal/osbuild2/stage.go | 2 ++ internal/osbuild2/stage_test.go | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/internal/osbuild2/stage.go b/internal/osbuild2/stage.go index 21d72225d..c392b5ca3 100644 --- a/internal/osbuild2/stage.go +++ b/internal/osbuild2/stage.go @@ -87,6 +87,8 @@ func (stage *Stage) UnmarshalJSON(data []byte) error { options = new(TimezoneStageOptions) case "org.osbuild.chrony": options = new(ChronyStageOptions) + case "org.osbuild.dracut": + options = new(DracutStageOptions) case "org.osbuild.dracut.conf": options = new(DracutConfStageOptions) case "org.osbuild.keymap": diff --git a/internal/osbuild2/stage_test.go b/internal/osbuild2/stage_test.go index 186c9e5fd..d6e2edda0 100644 --- a/internal/osbuild2/stage_test.go +++ b/internal/osbuild2/stage_test.go @@ -62,6 +62,16 @@ func TestStage_UnmarshalJSON(t *testing.T) { data: []byte(`{"type":"org.osbuild.chrony","options":{"timeservers":null}}`), }, }, + { + name: "dracut", + fields: fields{ + Type: "org.osbuild.dracut", + Options: &DracutStageOptions{}, + }, + args: args{ + data: []byte(`{"type":"org.osbuild.dracut","options":{"kernel":null}}`), + }, + }, { name: "dracut.conf", fields: fields{