| 1 | package ociclient |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "fmt" |
| 6 | "net/http" |
| 7 | "testing" |
| 8 | |
| 9 | "github.com/go-quicktest/qt" |
| 10 | ) |
| 11 | |
| 12 | func TestBadRepoName(t *testing.T) { |
| 13 | ctx := context.Background() |
| 14 | r, err := New("never.used", &Options{ |
| 15 | Insecure: true, |
| 16 | Transport: noTransport{}, |
| 17 | }) |
| 18 | qt.Assert(t, qt.IsNil(err)) |
| 19 | _, err = r.GetBlob(ctx, "Invalid--Repo", "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") |
| 20 | qt.Check(t, qt.ErrorMatches(err, "invalid OCI request: name invalid: invalid repository name")) |
| 21 | _, err = r.GetBlob(ctx, "okrepo", "bad-digest") |
| 22 | qt.Check(t, qt.ErrorMatches(err, "invalid OCI request: badly formed digest")) |
| 23 | _, err = r.ResolveTag(ctx, "okrepo", "bad-Tag!") |
| 24 | qt.Check(t, qt.ErrorMatches(err, "invalid OCI request: page not found")) |
| 25 | } |
| 26 | |
| 27 | type noTransport struct{} |
| 28 | |
| 29 | func (noTransport) RoundTrip(req *http.Request) (*http.Response, error) { |
| 30 | return nil, fmt.Errorf("no can do") |
| 31 | } |