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

Function TestFlakeRefString

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

Source from the content-addressed store, hash-verified

206}
207
208func TestFlakeRefString(t *testing.T) {
209 cases := map[Ref]string{
210 {}: "",
211
212 // Path references.
213 {Type: TypePath, Path: "."}: "path:.",
214 {Type: TypePath, Path: "./"}: "path:.",
215 {Type: TypePath, Path: "./flake"}: "path:flake",
216 {Type: TypePath, Path: "./relative/flake"}: "path:relative/flake",
217 {Type: TypePath, Path: "/"}: "path:/",
218 {Type: TypePath, Path: "/flake"}: "path:/flake",
219 {Type: TypePath, Path: "/absolute/flake"}: "path:/absolute/flake",
220
221 // Path references with escapes.
222 {Type: TypePath, Path: "%"}: "path:%25",
223 {Type: TypePath, Path: "/%2F"}: "path:/%252F",
224 {Type: TypePath, Path: "./Ûñî©ôδ€/flake\n"}: "path:%C3%9B%C3%B1%C3%AE%C2%A9%C3%B4%CE%B4%E2%82%AC/flake%0A",
225 {Type: TypePath, Path: "/Ûñî©ôδ€/flake\n"}: "path:/%C3%9B%C3%B1%C3%AE%C2%A9%C3%B4%CE%B4%E2%82%AC/flake%0A",
226
227 // Indirect references.
228 {Type: TypeIndirect, ID: "indirect"}: "flake:indirect",
229 {Type: TypeIndirect, ID: "indirect", Dir: "sub/dir"}: "flake:indirect?dir=sub%2Fdir",
230 {Type: TypeIndirect, ID: "indirect", Ref: "ref"}: "flake:indirect/ref",
231 {Type: TypeIndirect, ID: "indirect", Ref: "my/ref"}: "flake:indirect/my%2Fref",
232 {Type: TypeIndirect, ID: "indirect", Rev: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"}: "flake:indirect/5233fd2ba76a3accb5aaa999c00509a11fd0793c",
233 {Type: TypeIndirect, ID: "indirect", Ref: "ref", Rev: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"}: "flake:indirect/ref/5233fd2ba76a3accb5aaa999c00509a11fd0793c",
234
235 // GitHub references.
236 {Type: TypeGitHub, Owner: "NixOS", Repo: "nix"}: "github:NixOS/nix",
237 {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "v1.2.3"}: "github:NixOS/nix/v1.2.3",
238 {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "my/ref"}: "github:NixOS/nix/my%2Fref",
239 {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "5233fd2ba76a3accb5aaa999c00509a11fd0793c"}: "github:NixOS/nix/5233fd2ba76a3accb5aaa999c00509a11fd0793c",
240 {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Ref: "5233fd2bb76a3accb5aaa999c00509a11fd0793z"}: "github:NixOS/nix/5233fd2bb76a3accb5aaa999c00509a11fd0793z",
241 {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Rev: "5233fd2ba76a3accb5aaa999c00509a11fd0793c", Ref: "main"}: "github:NixOS/nix/5233fd2ba76a3accb5aaa999c00509a11fd0793c",
242 {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Dir: "sub/dir"}: "github:NixOS/nix?dir=sub%2Fdir",
243 {Type: TypeGitHub, Owner: "NixOS", Repo: "nix", Dir: "sub/dir", Host: "example.com"}: "github:NixOS/nix?dir=sub%2Fdir&host=example.com",
244
245 // Git references.
246 {Type: TypeGit, URL: "git://example.com/repo/flake"}: "git://example.com/repo/flake",
247 {Type: TypeGit, URL: "https://example.com/repo/flake"}: "git+https://example.com/repo/flake",
248 {Type: TypeGit, URL: "ssh://git@example.com/repo/flake"}: "git+ssh://git@example.com/repo/flake",
249 {Type: TypeGit, URL: "git:/repo/flake"}: "git:/repo/flake",
250 {Type: TypeGit, URL: "file:///repo/flake"}: "git+file:///repo/flake",
251 {Type: TypeGit, URL: "ssh://git@example.com/repo/flake", Ref: "my/ref", Rev: "e486d8d40e626a20e06d792db8cc5ac5aba9a5b4"}: "git+ssh://git@example.com/repo/flake?ref=my%2Fref&rev=e486d8d40e626a20e06d792db8cc5ac5aba9a5b4",
252 {Type: TypeGit, URL: "ssh://git@example.com/repo/flake?dir=sub%2Fdir", Ref: "my/ref", Rev: "e486d8d40e626a20e06d792db8cc5ac5aba9a5b4", Dir: "sub/dir"}: "git+ssh://git@example.com/repo/flake?dir=sub%2Fdir&ref=my%2Fref&rev=e486d8d40e626a20e06d792db8cc5ac5aba9a5b4",
253 {Type: TypeGit, URL: "git:repo/flake?dir=sub%2Fdir", Ref: "my/ref", Rev: "e486d8d40e626a20e06d792db8cc5ac5aba9a5b4", Dir: "sub/dir"}: "git:repo/flake?dir=sub%2Fdir&ref=my%2Fref&rev=e486d8d40e626a20e06d792db8cc5ac5aba9a5b4",
254
255 // Tarball references.
256 {Type: TypeTarball, URL: "http://example.com/flake"}: "tarball+http://example.com/flake",
257 {Type: TypeTarball, URL: "https://example.com/flake"}: "tarball+https://example.com/flake",
258 {Type: TypeTarball, URL: "https://example.com/flake", Dir: "sub/dir"}: "tarball+https://example.com/flake?dir=sub%2Fdir",
259 {Type: TypeTarball, URL: "file:///home/flake"}: "tarball+file:///home/flake",
260
261 // File URL references.
262 {Type: TypeFile, URL: "file:///flake"}: "file+file:///flake",
263 {Type: TypeFile, URL: "http://example.com/flake"}: "file+http://example.com/flake",
264 {Type: TypeFile, URL: "http://example.com/flake.git"}: "file+http://example.com/flake.git",
265 {Type: TypeFile, URL: "http://example.com/flake.tar?dir=sub%2Fdir", Dir: "sub/dir"}: "file+http://example.com/flake.tar?dir=sub%2Fdir",

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected