Skip to content

Commit

Permalink
remove unpointerify()
Browse files Browse the repository at this point in the history
  • Loading branch information
redradrat committed Nov 12, 2021
1 parent 9e7205a commit 24dc3f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 44 deletions.
10 changes: 3 additions & 7 deletions pkg/repositories/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ func RemoveRepository(name string) (RegistryModification, error) {
}

func UpdateRegistry(updates ...RegistryModification) error {
registry, err := unpointerify(Registry())
var registry RepoRegistry
ptrRegistry, err := Registry()
if err != nil {
return err
}
for _, update := range updates {
registry = update(registry)
registry = update(*ptrRegistry)
}

store, err := GetStoreFromConfig()
Expand Down Expand Up @@ -337,8 +338,3 @@ func RepoAuthExists(url string) (bool, error) {
func trimUrl(url string) string {
return strings.TrimSuffix(url, ".git")
}

func unpointerify(i *RepoRegistry, e error) (RepoRegistry, error) {
x := i
return *x, e
}
37 changes: 0 additions & 37 deletions pkg/repositories/store_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package repositories

import (
"errors"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -600,42 +599,6 @@ func Test_trimUrl(t *testing.T) {
}
}

func Test_unpointerify(t *testing.T) {
type args struct {
i *RepoRegistry
e error
}
tests := []struct {
name string
args args
want RepoRegistry
wantErr bool
}{
{name: "noerror", args: struct {
i *RepoRegistry
e error
}{i: &DemoRegistry, e: nil}, want: DemoRegistry, wantErr: false},
{name: "error", args: struct {
i *RepoRegistry
e error
}{i: &DemoRegistry, e: testPtrError}, want: DemoRegistry, wantErr: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := unpointerify(tt.args.i, tt.args.e)
if (err != nil) != tt.wantErr {
t.Errorf("unpointerify() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("unpointerify() got = %v, want %v", got, tt.want)
}
})
}
}

var testPtrError = errors.New("test")

func TestEtcdStore_readRegistry(t *testing.T) {

type fields struct {
Expand Down

0 comments on commit 24dc3f0

Please sign in to comment.