MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestFlakeInstallableString

Function TestFlakeInstallableString

nix/flake/flakeref_test.go:329–396  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

327}
328
329func TestFlakeInstallableString(t *testing.T) {
330 cases := map[Installable]string{
331 {}: "",
332
333 // No attribute or outputs.
334 {Ref: Ref{Type: TypePath, Path: "."}}: "path:.",
335 {Ref: Ref{Type: TypePath, Path: "./flake"}}: "path:flake",
336 {Ref: Ref{Type: TypePath, Path: "/flake"}}: "path:/flake",
337 {Ref: Ref{Type: TypeIndirect, ID: "indirect"}}: "flake:indirect",
338
339 // Attribute without outputs.
340 {AttrPath: "app", Ref: Ref{Type: TypePath, Path: "."}}: "path:.#app",
341 {AttrPath: "my#app", Ref: Ref{Type: TypePath, Path: "."}}: "path:.#my%23app",
342 {AttrPath: "app", Ref: Ref{Type: TypePath, Path: "./flake"}}: "path:flake#app",
343 {AttrPath: "my#app", Ref: Ref{Type: TypePath, Path: "./flake"}}: "path:flake#my%23app",
344 {AttrPath: "app", Ref: Ref{Type: TypePath, Path: "/flake"}}: "path:/flake#app",
345 {AttrPath: "my#app", Ref: Ref{Type: TypePath, Path: "/flake"}}: "path:/flake#my%23app",
346 {AttrPath: "app", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app",
347 {AttrPath: "my#app", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#my%23app",
348
349 // Attribute with single output.
350 {AttrPath: "app", Outputs: "out", Ref: Ref{Type: TypePath, Path: "."}}: "path:.#app^out",
351 {AttrPath: "app", Outputs: "out", Ref: Ref{Type: TypePath, Path: "./flake"}}: "path:flake#app^out",
352 {AttrPath: "app", Outputs: "out", Ref: Ref{Type: TypePath, Path: "/flake"}}: "path:/flake#app^out",
353 {AttrPath: "app", Outputs: "out", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app^out",
354
355 // Attribute with multiple outputs.
356 {AttrPath: "app", Outputs: "out,lib", Ref: Ref{Type: TypePath, Path: "."}}: "path:.#app^lib,out",
357 {AttrPath: "app", Outputs: "out,lib", Ref: Ref{Type: TypePath, Path: "./flake"}}: "path:flake#app^lib,out",
358 {AttrPath: "app", Outputs: "out,lib", Ref: Ref{Type: TypePath, Path: "/flake"}}: "path:/flake#app^lib,out",
359 {AttrPath: "app", Outputs: "out,lib", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app^lib,out",
360
361 // Outputs are cleaned and sorted.
362 {AttrPath: "app", Outputs: "out,lib", Ref: Ref{Type: TypePath, Path: "."}}: "path:.#app^lib,out",
363 {AttrPath: "app", Outputs: "lib,out", Ref: Ref{Type: TypePath, Path: "./flake"}}: "path:flake#app^lib,out",
364 {AttrPath: "app", Outputs: "out,,", Ref: Ref{Type: TypePath, Path: "/flake"}}: "path:/flake#app^out",
365 {AttrPath: "app", Outputs: ",lib,out", Ref: Ref{Type: TypePath, Path: "/flake"}}: "path:/flake#app^lib,out",
366 {AttrPath: "app", Outputs: ",", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app",
367
368 // Wildcard replaces other outputs.
369 {AttrPath: "app", Outputs: "*", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app^*",
370 {AttrPath: "app", Outputs: "out,*", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app^*",
371 {AttrPath: "app", Outputs: ",*", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app^*",
372
373 // Outputs are not percent-encoded.
374 {AttrPath: "app", Outputs: "%", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app^%",
375 {AttrPath: "app", Outputs: "/", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app^/",
376 {AttrPath: "app", Outputs: "%2F", Ref: Ref{Type: TypeIndirect, ID: "nixpkgs"}}: "flake:nixpkgs#app^%2F",
377
378 // Missing or invalid fields.
379 {AttrPath: "app", Ref: Ref{Type: TypeFile, URL: ""}}: "",
380 {AttrPath: "app", Ref: Ref{Type: TypeGit, URL: ""}}: "",
381 {AttrPath: "app", Ref: Ref{Type: TypeGitHub, Owner: ""}}: "",
382 {AttrPath: "app", Ref: Ref{Type: TypeIndirect, ID: ""}}: "",
383 {AttrPath: "app", Ref: Ref{Type: TypePath, Path: ""}}: "",
384 {AttrPath: "app", Ref: Ref{Type: TypeTarball, URL: ""}}: "",
385 }
386

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected