<commit_before>package image

import (
	"reflect"
	"testing"
)

func TestShortParseWithTag(t *testing.T) {

	reference, err := Parse("foo/bar:1.1")
	if err != nil {
		t.Fatalf("error while parsing tag: %s", err)
	}

	if reference.Remote() != DefaultRegistryHostname+"/foo/bar:1.1" {
		t.Errorf("unexpected remote: %s", reference.Remote())
	}

	if reference.Tag() != "1.1" {
		t.Errorf("unexpected tag: %s", reference.Tag())
	}

	if reference.Registry() != DefaultRegistryHostname {
		t.Errorf("unexpected registry: %s", reference.Registry())
	}

	if reference.ShortName() != "foo/bar" {
		t.Errorf("unexpected name: %s", reference.ShortName())
	}

	if reference.Name() != "foo/bar:1.1" {
		t.Errorf("unexpected name: %s", reference.Name())
	}

}

func TestParseRepo(t *testing.T) {
	type args struct {
		remote string
	}
	tests := []struct {
		name    string
		args    args
		want    *Repository
		wantErr bool
	}{
		{
			name: "foo/bar:1.1",
			args: args{remote: "foo/bar:1.1"},
			want: &Repository{
				Name:       "foo/bar:1.1",
				Repository: "index.docker.io/foo/bar",
				Remote:     "index.docker.io/foo/bar:1.1",
				Registry:   DefaultRegistryHostname,
				ShortName:  "foo/bar",
				Tag:        "1.1",
				Scheme:     "https",
			},
			wantErr: false,
		},
		{
			name: "localhost.localdomain/foo/bar:1.1",
			args: args{remote: "localhost.localdomain/foo/bar:1.1"},
			want: &Repository{
				Name:       "foo/bar:1.1",
				Repository: "localhost.localdomain/foo/bar",
				Remote:     "localhost.localdomain/foo/bar:1.1",
				Registry:   "localhost.localdomain",
				ShortName:  "foo/bar",
				Tag:        "1.1",
				Scheme:     "https",
			},
			wantErr: false,
		},
		{
			name: "https://httphost.sh/foo/bar:1.1",
			args: args{remote: "https://httphost.sh/foo/bar:1.1"},
			want: &Repository{
				Name:       "foo/bar:1.1",
				Repository: "httphost.sh/foo/bar",
				Remote:     "httphost.sh/foo/bar:1.1",
				Registry:   "httphost.sh",
				ShortName:  "foo/bar",
				Tag:        "1.1",
				Scheme:     "https",
			},
			wantErr: false,
		},
		{
			name: "localhost.localdomain/foo/bar (no tag)",
			args: args{remote: "localhost.localdomain/foo/bar"},
			want: &Repository{
				Name:       "foo/bar:latest",
				Repository: "localhost.localdomain/foo/bar",
				Remote:     "localhost.localdomain/foo/bar:latest",
				Registry:   "localhost.localdomain",
				ShortName:  "foo/bar",
				Tag:        "latest",
				Scheme:     "https",
			},
			wantErr: false,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, err := ParseRepo(tt.args.remote)
			if (err != nil) != tt.wantErr {
				t.Errorf("ParseRepo() error = %v, wantErr %v", err, tt.wantErr)
				return
			}
			if !reflect.DeepEqual(got, tt.want) {
				t.Errorf("ParseRepo() = %v, want %v", got, tt.want)
			}
		})
	}
}<commit_msg>additional parse test<commit_after>package image

import (
	"reflect"
	"testing"
)

func TestShortParseWithTag(t *testing.T) {

	reference, err := Parse("foo/bar:1.1")
	if err != nil {
		t.Fatalf("error while parsing tag: %s", err)
	}

	if reference.Remote() != DefaultRegistryHostname+"/foo/bar:1.1" {
		t.Errorf("unexpected remote: %s", reference.Remote())
	}

	if reference.Tag() != "1.1" {
		t.Errorf("unexpected tag: %s", reference.Tag())
	}

	if reference.Registry() != DefaultRegistryHostname {
		t.Errorf("unexpected registry: %s", reference.Registry())
	}

	if reference.ShortName() != "foo/bar" {
		t.Errorf("unexpected name: %s", reference.ShortName())
	}

	if reference.Name() != "foo/bar:1.1" {
		t.Errorf("unexpected name: %s", reference.Name())
	}

}

func TestParseRepo(t *testing.T) {
	type args struct {
		remote string
	}
	tests := []struct {
		name    string
		args    args
		want    *Repository
		wantErr bool
	}{
		{
			name: "foo/bar:1.1",
			args: args{remote: "foo/bar:1.1"},
			want: &Repository{
				Name:       "foo/bar:1.1",
				Repository: "index.docker.io/foo/bar",
				Remote:     "index.docker.io/foo/bar:1.1",
				Registry:   DefaultRegistryHostname,
				ShortName:  "foo/bar",
				Tag:        "1.1",
				Scheme:     "https",
			},
			wantErr: false,
		},
		{
			name: "localhost.localdomain/foo/bar:1.1",
			args: args{remote: "localhost.localdomain/foo/bar:1.1"},
			want: &Repository{
				Name:       "foo/bar:1.1",
				Repository: "localhost.localdomain/foo/bar",
				Remote:     "localhost.localdomain/foo/bar:1.1",
				Registry:   "localhost.localdomain",
				ShortName:  "foo/bar",
				Tag:        "1.1",
				Scheme:     "https",
			},
			wantErr: false,
		},
		{
			name: "https://httphost.sh/foo/bar:1.1",
			args: args{remote: "https://httphost.sh/foo/bar:1.1"},
			want: &Repository{
				Name:       "foo/bar:1.1",
				Repository: "httphost.sh/foo/bar",
				Remote:     "httphost.sh/foo/bar:1.1",
				Registry:   "httphost.sh",
				ShortName:  "foo/bar",
				Tag:        "1.1",
				Scheme:     "https",
			},
			wantErr: false,
		},
		{
			name: "localhost.localdomain/foo/bar (no tag)",
			args: args{remote: "localhost.localdomain/foo/bar"},
			want: &Repository{
				Name:       "foo/bar:latest",
				Repository: "localhost.localdomain/foo/bar",
				Remote:     "localhost.localdomain/foo/bar:latest",
				Registry:   "localhost.localdomain",
				ShortName:  "foo/bar",
				Tag:        "latest",
				Scheme:     "https",
			},
			wantErr: false,
		},
		{
			name: "git.technotrade.ua:4567/anatoliy/mysql-nafta:0.0.1 (semver)",
			args: args{remote: "git.technotrade.ua:4567/anatoliy/mysql-nafta:0.0.1"},
			want: &Repository{
				Name:       "anatoliy/mysql-nafta:0.0.1",
				Repository: "git.technotrade.ua:4567/anatoliy/mysql-nafta",
				Remote:     "git.technotrade.ua:4567/anatoliy/mysql-nafta:0.0.1",
				Registry:   "git.technotrade.ua:4567",
				ShortName:  "anatoliy/mysql-nafta",
				Tag:        "0.0.1",
				Scheme:     "https",
			},
			wantErr: false,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, err := ParseRepo(tt.args.remote)
			if (err != nil) != tt.wantErr {
				t.Errorf("ParseRepo() error = %v, wantErr %v", err, tt.wantErr)
				return
			}
			if !reflect.DeepEqual(got, tt.want) {
				t.Errorf("ParseRepo() = %v, want %v", got, tt.want)
			}
		})
	}
}
{'fraction_non_alphanumeric': 0.18293471234647704, 'fraction_numerical': 0.017937944408532643, 'mean_word_length': 2.789957134109002, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1970802', 'n_tokens_mistral': 2748, 'n_tokens_neox': 2366, 'n_words': 422}