github.com/drone/runner-go@v1.12.0/registry/file_test.go (about)

     1  // Copyright 2019 Drone.IO Inc. All rights reserved.
     2  // Use of this source code is governed by the Polyform License
     3  // that can be found in the LICENSE file.
     4  
     5  package registry
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/drone/drone-go/drone"
    11  	"github.com/google/go-cmp/cmp"
    12  )
    13  
    14  func TestFile(t *testing.T) {
    15  	p := File("auths/testdata/config.json")
    16  	got, err := p.List(noContext, nil)
    17  	if err != nil {
    18  		t.Error(err)
    19  		return
    20  	}
    21  	want := []*drone.Registry{
    22  		{
    23  			Address:  "index.docker.io",
    24  			Username: "octocat",
    25  			Password: "correct-horse-battery-staple",
    26  		},
    27  	}
    28  	if diff := cmp.Diff(got, want); diff != "" {
    29  		t.Errorf(diff)
    30  	}
    31  }
    32  
    33  func TestFileEmptyPath(t *testing.T) {
    34  	p := File("")
    35  	out, err := p.List(noContext, nil)
    36  	if err != nil {
    37  		t.Error(err)
    38  	}
    39  	if len(out) != 0 {
    40  		t.Errorf("Expect empty registry credentials")
    41  	}
    42  }