@@ -943,3 +943,86 @@ func TestPluginShouldClearRawEnvFromNestedSteps(t *testing.T) {
943943 assert .Nil (t , secondStep .RawEnv , "Second nested step RawEnv should be nil" )
944944 assert .Nil (t , secondStep .Build .RawEnv , "Second nested step Build.RawEnv should be nil" )
945945}
946+
947+ func TestPluginShouldPreserveDependsOnString (t * testing.T ) {
948+ param := `[{
949+ "github.com/buildkite-plugins/monorepo-diff-buildkite-plugin#commit": {
950+ "watch": [
951+ {
952+ "path": "service/**/*",
953+ "config": {
954+ "command": "echo deploy",
955+ "depends_on": "build-step"
956+ }
957+ }
958+ ]
959+ }
960+ }]`
961+
962+ got , err := initializePlugin (param )
963+ assert .NoError (t , err )
964+
965+ expected := Plugin {
966+ Diff : "git diff --name-only HEAD~1" ,
967+ Wait : false ,
968+ LogLevel : "info" ,
969+ Interpolation : true ,
970+ Watch : []WatchConfig {
971+ {
972+ Paths : []string {"service/**/*" },
973+ Step : Step {
974+ Command : "echo deploy" ,
975+ DependsOn : "build-step" ,
976+ },
977+ },
978+ },
979+ }
980+
981+ if diff := cmp .Diff (expected , got ); diff != "" {
982+ t .Fatalf ("plugin diff (-want +got):\n %s" , diff )
983+ }
984+ }
985+
986+ func TestPluginShouldPreserveDependsOnArray (t * testing.T ) {
987+ param := `[{
988+ "github.com/buildkite-plugins/monorepo-diff-buildkite-plugin#commit": {
989+ "watch": [
990+ {
991+ "path": "service/**/*",
992+ "config": {
993+ "trigger": "deploy-pipeline",
994+ "depends_on": ["build-step", "test-step"]
995+ }
996+ }
997+ ]
998+ }
999+ }]`
1000+
1001+ got , err := initializePlugin (param )
1002+ assert .NoError (t , err )
1003+
1004+ expected := Plugin {
1005+ Diff : "git diff --name-only HEAD~1" ,
1006+ Wait : false ,
1007+ LogLevel : "info" ,
1008+ Interpolation : true ,
1009+ Watch : []WatchConfig {
1010+ {
1011+ Paths : []string {"service/**/*" },
1012+ Step : Step {
1013+ Trigger : "deploy-pipeline" ,
1014+ Build : Build {
1015+ Message : "fix: temp file not correctly deleted" ,
1016+ Branch : "go-rewrite" ,
1017+ Commit : "123" ,
1018+ },
1019+ DependsOn : []interface {}{"build-step" , "test-step" },
1020+ },
1021+ },
1022+ },
1023+ }
1024+
1025+ if diff := cmp .Diff (expected , got ); diff != "" {
1026+ t .Fatalf ("plugin diff (-want +got):\n %s" , diff )
1027+ }
1028+ }
0 commit comments