1
1
package action
2
2
3
3
import (
4
+ "context"
4
5
"encoding/json"
5
6
"errors"
6
7
"fmt"
@@ -31,7 +32,7 @@ type mockDriver struct {
31
32
func (d * mockDriver ) Handles (imageType string ) bool {
32
33
return d .shouldHandle
33
34
}
34
- func (d * mockDriver ) Run (op * driver.Operation ) (driver.OperationResult , error ) {
35
+ func (d * mockDriver ) Run (ctx context. Context , op * driver.Operation ) (driver.OperationResult , error ) {
35
36
d .Operation = op
36
37
fmt .Fprintln (op .Out , "mocked running the bundle" )
37
38
return d .Result , d .Error
@@ -720,7 +721,7 @@ func TestAction_RunAction(t *testing.T) {
720
721
inst := New (d )
721
722
inst .SaveLogs = true
722
723
723
- opResult , claimResult , err := inst .Run (c , mockSet , out )
724
+ opResult , claimResult , err := inst .Run (context . Background (), c , mockSet , out )
724
725
require .NoError (t , err )
725
726
require .NoError (t , opResult .Error )
726
727
assert .Equal (t , claim .ActionInstall , c .Action )
@@ -748,7 +749,7 @@ func TestAction_RunAction(t *testing.T) {
748
749
inst := New (d )
749
750
inst .SaveLogs = false
750
751
751
- opResult , _ , err := inst .Run (c , mockSet , out )
752
+ opResult , _ , err := inst .Run (context . Background (), c , mockSet , out )
752
753
require .NoError (t , err )
753
754
require .NoError (t , opResult .Error )
754
755
@@ -772,7 +773,7 @@ func TestAction_RunAction(t *testing.T) {
772
773
op .Files ["/tmp/another/path" ] = "ANOTHER FILE"
773
774
return nil
774
775
}
775
- _ , _ , err := inst .Run (c , mockSet , out , addFile )
776
+ _ , _ , err := inst .Run (context . Background (), c , mockSet , out , addFile )
776
777
require .NoError (t , err )
777
778
assert .Contains (t , d .Operation .Files , "/tmp/another/path" )
778
779
})
@@ -792,7 +793,7 @@ func TestAction_RunAction(t *testing.T) {
792
793
sabotage := func (op * driver.Operation ) error {
793
794
return errors .New ("oops" )
794
795
}
795
- _ , _ , err := inst .Run (c , mockSet , out , sabotage )
796
+ _ , _ , err := inst .Run (context . Background (), c , mockSet , out , sabotage )
796
797
require .EqualError (t , err , "oops" )
797
798
})
798
799
@@ -805,7 +806,7 @@ func TestAction_RunAction(t *testing.T) {
805
806
Error : nil ,
806
807
}
807
808
inst := New (d )
808
- _ , claimResult , err := inst .Run (c , mockSet , out )
809
+ _ , claimResult , err := inst .Run (context . Background (), c , mockSet , out )
809
810
require .NoError (t , err )
810
811
assert .Equal (t , claim .ActionInstall , c .Action )
811
812
assert .Equal (t , claim .StatusSucceeded , claimResult .Status )
@@ -848,7 +849,7 @@ func TestAction_RunAction(t *testing.T) {
848
849
Error : nil ,
849
850
}
850
851
inst := New (d )
851
- opResult , _ , err := inst .Run (c , mockSet , out )
852
+ opResult , _ , err := inst .Run (context . Background (), c , mockSet , out )
852
853
require .NoError (t , err )
853
854
854
855
assert .Contains (t , opResult .Outputs , "hasDefault1" , "the output always applies so an output value should have been set" )
@@ -873,7 +874,7 @@ func TestAction_RunAction(t *testing.T) {
873
874
Error : nil ,
874
875
}
875
876
inst := New (d )
876
- opResult , _ , err := inst .Run (c , mockSet , out )
877
+ opResult , _ , err := inst .Run (context . Background (), c , mockSet , out )
877
878
require .NoError (t , err )
878
879
require .Contains (t , opResult .Error .Error (), "required output noDefault is missing and has no default" )
879
880
})
@@ -885,7 +886,7 @@ func TestAction_RunAction(t *testing.T) {
885
886
Error : errors .New ("I always fail" ),
886
887
}
887
888
inst := New (d )
888
- _ , _ , err := inst .Run (c , mockSet , out )
889
+ _ , _ , err := inst .Run (context . Background (), c , mockSet , out )
889
890
require .Error (t , err )
890
891
})
891
892
@@ -901,7 +902,7 @@ func TestAction_RunAction(t *testing.T) {
901
902
Error : errors .New ("I always fail" ),
902
903
}
903
904
inst := New (d )
904
- opResult , claimResult , err := inst .Run (c , mockSet , out )
905
+ opResult , claimResult , err := inst .Run (context . Background (), c , mockSet , out )
905
906
require .NoError (t , err )
906
907
require .Contains (t , opResult .Error .Error (), "I always fail" )
907
908
assert .Equal (t , claim .ActionInstall , c .Action )
@@ -922,7 +923,7 @@ func TestAction_RunAction(t *testing.T) {
922
923
Error : errors .New ("I always fail" ),
923
924
}
924
925
inst := New (d )
925
- opResult , claimResult , err := inst .Run (c , mockSet , out )
926
+ opResult , claimResult , err := inst .Run (context . Background (), c , mockSet , out )
926
927
require .Error (t , err , "Unknown action should fail" )
927
928
require .NoError (t , opResult .Error )
928
929
assert .Empty (t , claimResult )
0 commit comments