(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func Test_resolveAgentAbsPath(t *testing.T) { |
| 14 | t.Parallel() |
| 15 | |
| 16 | type args struct { |
| 17 | workingDirectory string |
| 18 | relOrAbsPath string |
| 19 | agentOS string |
| 20 | local bool |
| 21 | } |
| 22 | tests := []struct { |
| 23 | name string |
| 24 | args args |
| 25 | want string |
| 26 | wantErr bool |
| 27 | }{ |
| 28 | {"ok no args", args{}, "", false}, |
| 29 | {"ok only working directory", args{workingDirectory: "/workdir"}, "/workdir", false}, |
| 30 | {"ok with working directory and rel path", args{workingDirectory: "/workdir", relOrAbsPath: "my/path"}, "/workdir/my/path", false}, |
| 31 | {"ok with working directory and abs path", args{workingDirectory: "/workdir", relOrAbsPath: "/my/path"}, "/my/path", false}, |
| 32 | {"ok with no working directory and abs path", args{relOrAbsPath: "/my/path"}, "/my/path", false}, |
| 33 | |
| 34 | {"fail tilde", args{relOrAbsPath: "~"}, "", true}, |
| 35 | {"fail tilde with working directory", args{workingDirectory: "/workdir", relOrAbsPath: "~"}, "", true}, |
| 36 | {"fail tilde path", args{relOrAbsPath: "~/workdir"}, "", true}, |
| 37 | {"fail tilde path with working directory", args{workingDirectory: "/workdir", relOrAbsPath: "~/workdir"}, "", true}, |
| 38 | {"fail relative dot with no working directory", args{relOrAbsPath: "."}, "", true}, |
| 39 | {"fail relative with no working directory", args{relOrAbsPath: "workdir"}, "", true}, |
| 40 | |
| 41 | {"ok with working directory and rel path on windows", args{workingDirectory: "C:\\workdir", relOrAbsPath: "my\\path", agentOS: "windows"}, "C:\\workdir\\my\\path", false}, |
| 42 | {"ok with working directory and abs path on windows", args{workingDirectory: "C:\\workdir", relOrAbsPath: "C:\\my\\path", agentOS: "windows"}, "C:\\my\\path", false}, |
| 43 | {"ok with no working directory and abs path on windows", args{relOrAbsPath: "C:\\my\\path", agentOS: "windows"}, "C:\\my\\path", false}, |
| 44 | {"ok abs unix path on windows", args{workingDirectory: "C:\\workdir", relOrAbsPath: "/my/path", agentOS: "windows"}, "\\my\\path", false}, |
| 45 | {"ok rel unix path on windows", args{workingDirectory: "C:\\workdir", relOrAbsPath: "my/path", agentOS: "windows"}, "C:\\workdir\\my\\path", false}, |
| 46 | |
| 47 | {"fail with no working directory and rel path on windows", args{relOrAbsPath: "my\\path", agentOS: "windows"}, "", true}, |
| 48 | } |
| 49 | for _, tt := range tests { |
| 50 | t.Run(tt.name, func(t *testing.T) { |
| 51 | t.Parallel() |
| 52 | |
| 53 | got, err := resolveAgentAbsPath(tt.args.workingDirectory, tt.args.relOrAbsPath, tt.args.agentOS, tt.args.local) |
| 54 | if (err != nil) != tt.wantErr { |
| 55 | t.Errorf("resolveAgentAbsPath() error = %v, wantErr %v", err, tt.wantErr) |
| 56 | return |
| 57 | } |
| 58 | if got != tt.want { |
| 59 | t.Errorf("resolveAgentAbsPath() = %v, want %v", got, tt.want) |
| 60 | } |
| 61 | }) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func Test_buildAppLinkURL(t *testing.T) { |
| 66 | t.Parallel() |
nothing calls this directly
no test coverage detected