Skip to content

Commit

Permalink
Fix tests to use gadget "install" folder
Browse files Browse the repository at this point in the history
  • Loading branch information
upils committed Oct 24, 2023
1 parent c63c014 commit d37b893
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions internal/statemachine/classic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,12 @@ func TestPrepareGadgetTree(t *testing.T) {
asserter.AssertErrNil(err, true)

// place a test gadget tree in the scratch directory so we don't have to build one
gadgetDir := filepath.Join(stateMachine.tempDirs.scratch, "gadget")
err = os.MkdirAll(gadgetDir, 0755)
asserter.AssertErrNil(err, true)

gadgetSource := filepath.Join("testdata", "gadget_tree")
gadgetDest := filepath.Join(stateMachine.tempDirs.scratch, "gadget", "install")
err = osutil.CopySpecialFile(gadgetSource, gadgetDest)
err = osutil.CopySpecialFile(gadgetSource, filepath.Join(gadgetDir, "install"))
asserter.AssertErrNil(err, true)

err = stateMachine.prepareGadgetTree()
Expand Down Expand Up @@ -503,9 +506,12 @@ func TestFailedPrepareGadgetTree(t *testing.T) {
asserter.AssertErrNil(err, true)

// place a test gadget tree in the scratch directory so we don't have to build one
gadgetDir := filepath.Join(stateMachine.tempDirs.scratch, "gadget")
err = os.MkdirAll(gadgetDir, 0755)
asserter.AssertErrNil(err, true)

gadgetSource := filepath.Join("testdata", "gadget_tree")
gadgetDest := filepath.Join(stateMachine.tempDirs.scratch, "gadget", "install")
err = osutil.CopySpecialFile(gadgetSource, gadgetDest)
err = osutil.CopySpecialFile(gadgetSource, filepath.Join(gadgetDir, "install"))
asserter.AssertErrNil(err, true)

// mock os.Mkdir
Expand Down Expand Up @@ -4235,8 +4241,12 @@ func TestFailedUpdateBootloader(t *testing.T) {

// place a test gadget tree in the scratch directory so we don't
// have to build one
gadgetDir := filepath.Join(stateMachine.tempDirs.scratch, "gadget")
err = os.MkdirAll(gadgetDir, 0755)
asserter.AssertErrNil(err, true)

gadgetSource := filepath.Join("testdata", "gadget_tree")
gadgetDest := filepath.Join(stateMachine.tempDirs.scratch, "gadget", "install")
gadgetDest := filepath.Join(gadgetDir, "install")
err = osutil.CopySpecialFile(gadgetSource, gadgetDest)
asserter.AssertErrNil(err, true)
// also copy gadget.yaml to the root of the scratch/gadget dir
Expand Down Expand Up @@ -4294,8 +4304,12 @@ func TestUnsupportedBootloader(t *testing.T) {

// place a test gadget tree in the scratch directory so we don't
// have to build one
gadgetDir := filepath.Join(stateMachine.tempDirs.scratch, "gadget")
err = os.MkdirAll(gadgetDir, 0755)
asserter.AssertErrNil(err, true)

gadgetSource := filepath.Join("testdata", "gadget_tree")
gadgetDest := filepath.Join(stateMachine.tempDirs.scratch, "gadget", "install")
gadgetDest := filepath.Join(gadgetDir, "install")
err = osutil.CopySpecialFile(gadgetSource, gadgetDest)
asserter.AssertErrNil(err, true)
// also copy gadget.yaml to the root of the scratch/gadget dir
Expand Down

0 comments on commit d37b893

Please sign in to comment.