(t *testing.T)
| 244 | } |
| 245 | |
| 246 | func TestGetLocalPath(t *testing.T) { |
| 247 | tests := []struct { |
| 248 | name string |
| 249 | repo string |
| 250 | chartpath string |
| 251 | expect string |
| 252 | winExpect string |
| 253 | err bool |
| 254 | }{ |
| 255 | { |
| 256 | name: "absolute path", |
| 257 | repo: "file:////", |
| 258 | expect: "/", |
| 259 | winExpect: "\\", |
| 260 | }, |
| 261 | { |
| 262 | name: "relative path", |
| 263 | repo: "file://../../testdata/chartpath/base", |
| 264 | chartpath: "foo/bar", |
| 265 | expect: "testdata/chartpath/base", |
| 266 | winExpect: "testdata\\chartpath\\base", |
| 267 | }, |
| 268 | { |
| 269 | name: "current directory path", |
| 270 | repo: "../charts/localdependency", |
| 271 | chartpath: "testdata/chartpath/charts", |
| 272 | expect: "testdata/chartpath/charts/localdependency", |
| 273 | winExpect: "testdata\\chartpath\\charts\\localdependency", |
| 274 | }, |
| 275 | { |
| 276 | name: "invalid local path", |
| 277 | repo: "file://testdata/nonexistent", |
| 278 | chartpath: "testdata/chartpath", |
| 279 | err: true, |
| 280 | }, |
| 281 | { |
| 282 | name: "invalid path under current directory", |
| 283 | repo: "charts/nonexistentdependency", |
| 284 | chartpath: "testdata/chartpath/charts", |
| 285 | err: true, |
| 286 | }, |
| 287 | } |
| 288 | |
| 289 | for _, tt := range tests { |
| 290 | t.Run(tt.name, func(t *testing.T) { |
| 291 | p, err := GetLocalPath(tt.repo, tt.chartpath) |
| 292 | if err != nil { |
| 293 | if tt.err { |
| 294 | return |
| 295 | } |
| 296 | t.Fatal(err) |
| 297 | } |
| 298 | if tt.err { |
| 299 | t.Fatalf("Expected error in test %q", tt.name) |
| 300 | } |
| 301 | expect := tt.expect |
| 302 | if runtime.GOOS == "windows" { |
| 303 | expect = tt.winExpect |
nothing calls this directly
no test coverage detected
searching dependent graphs…