Skip to content

Commit

Permalink
add logs for mostRecent test
Browse files Browse the repository at this point in the history
Signed-off-by: hanen mizouni <hanen.mizouni@outscale.com>
  • Loading branch information
outscale-hmi committed Oct 13, 2022
1 parent caf0404 commit b17acfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions builder/osc/common/step_source_omi_info_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package common

import (
"fmt"
"testing"

"github.com/hashicorp/packer-plugin-sdk/multistep"
Expand All @@ -13,22 +14,23 @@ import (
)

// Create statebag for running test
func getState() multistep.StateBag {
func getState() (multistep.StateBag, error) {
state := new(multistep.BasicStateBag)
accessConfig := &AccessConfig{}
accessConfig.RawRegion = "eu-west-2"
var oscConn *osc.APIClient
var err error
if oscConn, err = accessConfig.NewOSCClient(); err != nil {
return nil
err := fmt.Errorf("error in creating osc Client: %s", err.Error())
return nil, err
}
state.Put("osc", oscConn)
state.Put("ui", &packersdk.BasicUi{
Reader: new(bytes.Buffer),
Writer: new(bytes.Buffer),
})
state.Put("accessConfig", accessConfig)
return state
return state, err
}

func TestMostRecentOmiFilter(t *testing.T) {
Expand All @@ -38,9 +40,9 @@ func TestMostRecentOmiFilter(t *testing.T) {
MostRecent: true,
},
}
state := getState()
state, err := getState()
if state == nil {
t.Fatalf("error retrieving state, but")
t.Fatalf("error retrieving state %s", err.Error())
}

action := stepSourceOMIInfo.Run(context.Background(), state)
Expand Down
2 changes: 1 addition & 1 deletion example/most_recent_test.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ source "outscale-bsusurrogate" "test" {

build {
sources = [ "source.outscale-bsusurrogate.test" ]
}
}

0 comments on commit b17acfe

Please sign in to comment.