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

Function TestParseFlakeRef

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

Source from the content-addressed store, hash-verified

7)
8
9func TestParseFlakeRef(t *testing.T) {
10 cases := map[string]Ref{
11 // Path-like references start with a '.' or '/'.
12 // This distinguishes them from indirect references
13 // (./nixpkgs is a directory; nixpkgs is an indirect).
14 ".": {Type: TypePath, Path: "."},
15 "./": {Type: TypePath, Path: "./"},
16 "./flake": {Type: TypePath, Path: "./flake"},
17 "./relative/flake": {Type: TypePath, Path: "./relative/flake"},
18 "/": {Type: TypePath, Path: "/"},
19 "/flake": {Type: TypePath, Path: "/flake"},
20 "/absolute/flake": {Type: TypePath, Path: "/absolute/flake"},
21
22 // Path-like references can have raw unicode characters unlike
23 // path: URL references.
24 "./Ûñî©ôδ€/flake\n": {Type: TypePath, Path: "./Ûñî©ôδ€/flake\n"},
25 "/Ûñî©ôδ€/flake\n": {Type: TypePath, Path: "/Ûñî©ôδ€/flake\n"},
26
27 // URL-like path references.
28 "path:": {Type: TypePath, Path: ""},
29 "path:.": {Type: TypePath, Path: "."},
30 "path:./": {Type: TypePath, Path: "./"},
31 "path:./flake": {Type: TypePath, Path: "./flake"},
32 "path:./relative/flake": {Type: TypePath, Path: "./relative/flake"},
33 "path:./relative/my%20flake": {Type: TypePath, Path: "./relative/my flake"},
34 "path:/": {Type: TypePath, Path: "/"},
35 "path:/flake": {Type: TypePath, Path: "/flake"},
36 "path:/absolute/flake": {Type: TypePath, Path: "/absolute/flake"},
37 "path:/absolute/flake?lastModified=1734435836&narHash=sha256-kMBQ5PRiFLagltK0sH%2B08aiNt3zGERC2297iB6vrvlU%3D": {Type: TypePath, Path: "/absolute/flake", LastModified: 1734435836, NARHash: "sha256-kMBQ5PRiFLagltK0sH+08aiNt3zGERC2297iB6vrvlU="},
38
39 // URL-like paths can omit the "./" prefix for relative
40 // directories.
41 "path:flake": {Type: TypePath, Path: "flake"},
42 "path:relative/flake": {Type: TypePath, Path: "relative/flake"},
43
44 // Indirect references.
45 "flake:indirect": {Type: TypeIndirect, ID: "indirect"},
46 "flake:indirect/ref": {Type: TypeIndirect, ID: "indirect", Ref: "ref"},
47 "flake:indirect/my%2Fref": {Type: TypeIndirect, ID: "indirect", Ref: "my/ref"},
48 "flake:indirect/5233fd2ba76a3accb5aaa999c00509a11fd0793c": {Type: TypeIndirect, ID: "indirect", Rev: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"},
49 "flake:indirect/ref/5233fd2ba76a3accb5aaa999c00509a11fd0793c": {Type: TypeIndirect, ID: "indirect", Ref: "ref", Rev: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"},
50
51 // Indirect references can omit their "indirect:" type prefix.
52 "indirect": {Type: TypeIndirect, ID: "indirect"},
53 "indirect/ref": {Type: TypeIndirect, ID: "indirect", Ref: "ref"},
54 "indirect/5233fd2ba76a3accb5aaa999c00509a11fd0793c": {Type: TypeIndirect, ID: "indirect", Rev: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"},
55 "indirect/ref/5233fd2ba76a3accb5aaa999c00509a11fd0793c": {Type: TypeIndirect, ID: "indirect", Ref: "ref", Rev: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"},
56
57 // GitHub references.
58 "github:NixOS/nix": {Type: TypeGitHub, Owner: "NixOS", Repo: "nix"},
59 "github:NixOS/nix/v1.2.3": {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "v1.2.3"},
60 "github:NixOS/nix?ref=v1.2.3": {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "v1.2.3"},
61 "github:NixOS/nix?ref=5233fd2ba76a3accb5aaa999c00509a11fd0793c": {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"},
62 "github:NixOS/nix/main": {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "main"},
63 "github:NixOS/nix/main/5233fd2ba76a3accb5aaa999c00509a11fd0793c": {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "main/5233fd2ba76a3accb5aaa999c00509a11fd0793c"},
64 "github:NixOS/nix/5233fd2bb76a3accb5aaa999c00509a11fd0793z": {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "5233fd2bb76a3accb5aaa999c00509a11fd0793z"},
65 "github:NixOS/nix/5233fd2ba76a3accb5aaa999c00509a11fd0793c": {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Rev: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"},
66 "github:NixOS/nix?rev=5233fd2ba76a3accb5aaa999c00509a11fd0793c": {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Rev: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"},

Callers

nothing calls this directly

Calls 2

ParseRefFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected