package hw3test import ( "reflect" "testing" ) func TestSplitCommand(t *testing.T) { for _, test := range []struct { name string command string want []string wantErr bool }{ { name: "working directory with spaces", command: `python3 "../solution with spaces/server.py" "--working-directory=C:\Users\student name\files"`, want: []string{"python3", "../solution with spaces/server.py", `--working-directory=C:\Users\student name\files`}, }, { name: "Docker volume with spaces", command: `docker run -v "C:\Users\student name\files:/files" hw3img`, want: []string{"docker", "run", "-v", `C:\Users\student name\files:/files`, "hw3img"}, }, {name: "empty command", command: " ", wantErr: true}, {name: "unclosed quote", command: `python3 "unterminated`, wantErr: true}, } { t.Run(test.name, func(t *testing.T) { got, err := splitCommand(test.command) if (err != nil) != test.wantErr { t.Fatalf("splitCommand(%q) error = %v, wantErr %v", test.command, err, test.wantErr) } if !reflect.DeepEqual(got, test.want) { t.Fatalf("splitCommand(%q) = %#v, want %#v", test.command, got, test.want) } }) } }