Skip to content

Commit

Permalink
internal/urlutil: fix naming convention in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jroimartin committed Nov 24, 2023
1 parent dab2c61 commit fa72480
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions internal/urlutil/urlutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestGet_file(t *testing.T) {
}
}

func TestGet_HTTP(t *testing.T) {
func TestGet_http(t *testing.T) {
tests := []struct {
name string
handlerFunc func(http.ResponseWriter, *http.Request)
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestGet_HTTP(t *testing.T) {
}
}

func TestGetOCI(t *testing.T) {
func TestGet_oci(t *testing.T) {
tests := []struct {
name string
file string
Expand Down Expand Up @@ -174,42 +174,6 @@ func TestGetOCI(t *testing.T) {
}
}

func pushArtifact(reg, name, tag string) error {
fs, err := file.New("")
if err != nil {
return fmt.Errorf("create file store: %w", err)
}
defer fs.Close()

desc, err := fs.Add(context.Background(), name, "application/vnd.test.file", "")
if err != nil {
return fmt.Errorf("add file: %w", err)
}

opts := oras.PackManifestOptions{
Layers: []ocispec.Descriptor{desc},
}
descManifest, err := oras.PackManifest(context.Background(), fs, oras.PackManifestVersion1_1_RC4, "application/vnd.test.manifest", opts)
if err != nil {
return fmt.Errorf("pack manifest: %w", err)
}

if err := fs.Tag(context.Background(), descManifest, tag); err != nil {
return fmt.Errorf("tag artifact: %w", err)
}

repo, err := remote.NewRepository(reg + "/" + name)
if err != nil {
return fmt.Errorf("new repository: %w", err)
}
repo.PlainHTTP = true

if _, err := oras.Copy(context.Background(), fs, tag, repo, tag, oras.DefaultCopyOptions); err != nil {
return fmt.Errorf("copy artifact: %w", err)
}
return nil
}

func TestGet_invalid_URL(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -261,3 +225,39 @@ func TestGet_invalid_URL(t *testing.T) {
})
}
}

func pushArtifact(reg, name, tag string) error {
fs, err := file.New("")
if err != nil {
return fmt.Errorf("create file store: %w", err)
}
defer fs.Close()

desc, err := fs.Add(context.Background(), name, "application/vnd.test.file", "")
if err != nil {
return fmt.Errorf("add file: %w", err)
}

opts := oras.PackManifestOptions{
Layers: []ocispec.Descriptor{desc},
}
descManifest, err := oras.PackManifest(context.Background(), fs, oras.PackManifestVersion1_1_RC4, "application/vnd.test.manifest", opts)
if err != nil {
return fmt.Errorf("pack manifest: %w", err)
}

if err := fs.Tag(context.Background(), descManifest, tag); err != nil {
return fmt.Errorf("tag artifact: %w", err)
}

repo, err := remote.NewRepository(reg + "/" + name)
if err != nil {
return fmt.Errorf("new repository: %w", err)
}
repo.PlainHTTP = true

if _, err := oras.Copy(context.Background(), fs, tag, repo, tag, oras.DefaultCopyOptions); err != nil {
return fmt.Errorf("copy artifact: %w", err)
}
return nil
}

0 comments on commit fa72480

Please sign in to comment.