(t *testing.T)
| 277 | } |
| 278 | |
| 279 | func TestParseFlakeInstallable(t *testing.T) { |
| 280 | cases := map[string]Installable{ |
| 281 | // Empty string is not a valid installable. |
| 282 | "": {}, |
| 283 | |
| 284 | // Not a path and not a valid URL. |
| 285 | "://bad/url": {}, |
| 286 | |
| 287 | ".": {Ref: Ref{Type: TypePath, Path: "."}}, |
| 288 | ".#app": {AttrPath: "app", Ref: Ref{Type: TypePath, Path: "."}}, |
| 289 | ".#app^out": {AttrPath: "app", Outputs: "out", Ref: Ref{Type: TypePath, Path: "."}}, |
| 290 | ".#app^out,lib": {AttrPath: "app", Outputs: "lib,out", Ref: Ref{Type: TypePath, Path: "."}}, |
| 291 | ".#app^*": {AttrPath: "app", Outputs: "*", Ref: Ref{Type: TypePath, Path: "."}}, |
| 292 | ".^*": {Outputs: "*", Ref: Ref{Type: TypePath, Path: "."}}, |
| 293 | |
| 294 | "./flake": {Ref: Ref{Type: TypePath, Path: "./flake"}}, |
| 295 | "./flake#app": {AttrPath: "app", Ref: Ref{Type: TypePath, Path: "./flake"}}, |
| 296 | "./flake#app^out": {AttrPath: "app", Outputs: "out", Ref: Ref{Type: TypePath, Path: "./flake"}}, |
| 297 | "./flake#app^out,lib": {AttrPath: "app", Outputs: "lib,out", Ref: Ref{Type: TypePath, Path: "./flake"}}, |
| 298 | "./flake^out": {Outputs: "out", Ref: Ref{Type: TypePath, Path: "./flake"}}, |
| 299 | |
| 300 | "indirect": {Ref: Ref{Type: TypeIndirect, ID: "indirect"}}, |
| 301 | "nixpkgs#app": {AttrPath: "app", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}, |
| 302 | "nixpkgs#app^out": {AttrPath: "app", Outputs: "out", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}, |
| 303 | "nixpkgs#app^out,lib": {AttrPath: "app", Outputs: "lib,out", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}, |
| 304 | "nixpkgs^out": {Outputs: "out", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}, |
| 305 | |
| 306 | "%23#app": {AttrPath: "app", Ref: Ref{Type: TypeIndirect, ID: "#"}}, |
| 307 | "./%23#app": {AttrPath: "app", Ref: Ref{Type: TypePath, Path: "./#"}}, |
| 308 | "/%23#app": {AttrPath: "app", Ref: Ref{Type: TypePath, Path: "/#"}}, |
| 309 | "path:/%23#app": {AttrPath: "app", Ref: Ref{Type: TypePath, Path: "/#"}}, |
| 310 | |
| 311 | "http://example.com/%23.tar#app": {AttrPath: "app", Ref: Ref{Type: TypeTarball, URL: "http://example.com/%23.tar"}}, |
| 312 | "file:///flake#app": {AttrPath: "app", Ref: Ref{Type: TypeFile, URL: "file:///flake"}}, |
| 313 | "git://example.com/repo/flake#app": {AttrPath: "app", Ref: Ref{Type: TypeGit, URL: "git://example.com/repo/flake"}}, |
| 314 | } |
| 315 | |
| 316 | for installable, want := range cases { |
| 317 | t.Run(installable, func(t *testing.T) { |
| 318 | got, err := ParseInstallable(installable) |
| 319 | if diff := cmp.Diff(want, got); diff != "" { |
| 320 | if err != nil { |
| 321 | t.Errorf("got error: %s", err) |
| 322 | } |
| 323 | t.Errorf("wrong installable (-want +got):\n%s", diff) |
| 324 | } |
| 325 | }) |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | func TestFlakeInstallableString(t *testing.T) { |
| 330 | cases := map[Installable]string{ |
nothing calls this directly
no test coverage detected