@@ -885,3 +885,83 @@ func TestEnvHelperBranches(t *testing.T) {
885885 t .Fatalf ("getenvList=%v ok=%t" , list , ok )
886886 }
887887}
888+
889+ func TestNamespaceDevboxSizeForConfig (t * testing.T ) {
890+ for _ , tc := range []struct {
891+ name string
892+ cfg Config
893+ want string
894+ }{
895+ {name : "explicit namespace size" , cfg : Config {Namespace : NamespaceConfig {Size : " xl " }, Class : "standard" }, want : "XL" },
896+ {name : "explicit server type" , cfg : Config {ServerType : " l " , ServerTypeExplicit : true , Class : "standard" }, want : "L" },
897+ {name : "class default" , cfg : Config {Class : "large" }, want : "L" },
898+ {name : "empty default" , cfg : Config {}, want : "M" },
899+ {name : "custom class" , cfg : Config {Class : "gpu" }, want : "GPU" },
900+ } {
901+ t .Run (tc .name , func (t * testing.T ) {
902+ if got := namespaceDevboxSizeForConfig (tc .cfg ); got != tc .want {
903+ t .Fatalf ("size=%q want %q" , got , tc .want )
904+ }
905+ })
906+ }
907+ }
908+
909+ func TestApplyFileJobConfigCoversJobOptions (t * testing.T ) {
910+ enabled := true
911+ disabled := false
912+ job := applyFileJobConfig (JobConfig {}, fileJobConfig {
913+ Provider : "aws" ,
914+ TargetOS : targetLinux ,
915+ Windows : & fileWindowsConfig {Mode : windowsModeWSL2 },
916+ Profile : "ci" ,
917+ Class : "large" ,
918+ Type : "m8i.large" ,
919+ Capacity : & fileCapacityConfig {Market : "spot" },
920+ Market : "on-demand" ,
921+ TTL : "45m" ,
922+ IdleTimeout : "5m" ,
923+ Desktop : & enabled ,
924+ Browser : & disabled ,
925+ Code : & enabled ,
926+ Network : "tailscale" ,
927+ Hydrate : & fileJobHydrateConfig {
928+ Actions : & enabled ,
929+ WaitTimeout : "12m" ,
930+ KeepAliveMinutes : 3 ,
931+ },
932+ Actions : & fileJobActionsConfig {
933+ Repo : "openclaw/crabbox" ,
934+ Workflow : ".github/workflows/ci.yml" ,
935+ Job : "test" ,
936+ Ref : "main" ,
937+ Fields : []string {"a=1" , "a=1" , "b=2" },
938+ },
939+ Shell : & enabled ,
940+ Command : "pnpm test" ,
941+ NoSync : & enabled ,
942+ SyncOnly : & disabled ,
943+ Checksum : & enabled ,
944+ ForceSyncLarge : & enabled ,
945+ JUnit : []string {"junit.xml" , "junit.xml" },
946+ Downloads : []string {"out=out" , "out=out" },
947+ Stop : "always" ,
948+ })
949+ if job .Provider != "aws" || job .Target != targetLinux || job .WindowsMode != windowsModeWSL2 || job .Profile != "ci" || job .Class != "large" || job .ServerType != "m8i.large" || job .Market != "on-demand" {
950+ t .Fatalf ("basic job fields not applied: %#v" , job )
951+ }
952+ if job .TTL != 45 * time .Minute || job .IdleTimeout != 5 * time .Minute {
953+ t .Fatalf ("job durations ttl=%s idle=%s" , job .TTL , job .IdleTimeout )
954+ }
955+ if job .Desktop == nil || ! * job .Desktop || job .Browser == nil || * job .Browser || job .Code == nil || ! * job .Code || job .Network != "tailscale" {
956+ t .Fatalf ("job UI/network fields not applied: %#v" , job )
957+ }
958+ if ! job .Hydrate .Actions || job .Hydrate .WaitTimeout != 12 * time .Minute || job .Hydrate .KeepAliveMinutes != 3 {
959+ t .Fatalf ("hydrate not applied: %#v" , job .Hydrate )
960+ }
961+ if job .Actions .Repo != "openclaw/crabbox" || job .Actions .Workflow != ".github/workflows/ci.yml" || job .Actions .Job != "test" || job .Actions .Ref != "main" || len (job .Actions .Fields ) != 2 {
962+ t .Fatalf ("actions not applied: %#v" , job .Actions )
963+ }
964+ if ! job .Shell || job .Command != "pnpm test" || ! job .NoSync || job .SyncOnly || job .Checksum == nil || ! * job .Checksum || ! job .ForceSyncLarge || len (job .JUnit ) != 1 || len (job .Downloads ) != 1 || job .Stop != "always" {
965+ t .Fatalf ("command/sync fields not applied: %#v" , job )
966+ }
967+ }
0 commit comments