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

Function TestParseFlakeRefError

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

Source from the content-addressed store, hash-verified

138}
139
140func TestParseFlakeRefError(t *testing.T) {
141 t.Run("EmptyString", func(t *testing.T) {
142 ref := ""
143 _, err := ParseRef(ref)
144 if err == nil {
145 t.Error("got nil error for bad flakeref:", ref)
146 }
147 })
148 t.Run("InvalidURL", func(t *testing.T) {
149 ref := "://bad/url"
150 _, err := ParseRef(ref)
151 if err == nil {
152 t.Error("got nil error for bad flakeref:", ref)
153 }
154 })
155 t.Run("InvalidURLEscape", func(t *testing.T) {
156 ref := "path:./relative/my%flake"
157 _, err := ParseRef(ref)
158 if err == nil {
159 t.Error("got nil error for bad flakeref:", ref)
160 }
161 })
162 t.Run("UnsupportedURLScheme", func(t *testing.T) {
163 ref := "runx:mvdan/gofumpt@latest"
164 _, err := ParseRef(ref)
165 if err == nil {
166 t.Error("got nil error for bad flakeref:", ref)
167 }
168 })
169 t.Run("PathLikeWith?#", func(t *testing.T) {
170 in := []string{
171 "./invalid#path",
172 "./invalid?path",
173 "/invalid#path",
174 "/invalid?path",
175 "/#",
176 "/?",
177 }
178 for _, ref := range in {
179 _, err := ParseRef(ref)
180 if err == nil {
181 t.Error("got nil error for bad flakeref:", ref)
182 }
183 }
184 })
185 t.Run("GitHubInvalidRefRevCombo", func(t *testing.T) {
186 in := []string{
187 "github:NixOS/nix?ref=v1.2.3&rev=5233fd2ba76a3accb5aaa999c00509a11fd0793c",
188 "github:NixOS/nix/v1.2.3?ref=v4.5.6",
189 "github:NixOS/nix/5233fd2ba76a3accb5aaa999c00509a11fd0793c?rev=e486d8d40e626a20e06d792db8cc5ac5aba9a5b4",
190 "github:NixOS/nix/5233fd2ba76a3accb5aaa999c00509a11fd0793c?ref=v1.2.3",
191 }
192 for _, ref := range in {
193 _, err := ParseRef(ref)
194 if err == nil {
195 t.Error("got nil error for bad flakeref:", ref)
196 }
197 }

Callers

nothing calls this directly

Calls 3

ParseRefFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected