mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
credentials: don't fail tests early, and use consts
- use consts for fixed values in tests - don't fail tests early if there's more we can test Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -42,7 +42,7 @@ func (m *memoryStore) List() (map[string]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStore(t *testing.T) {
|
func TestStore(t *testing.T) {
|
||||||
serverURL := "https://index.docker.io/v1/"
|
const serverURL = "https://index.docker.io/v1/"
|
||||||
creds := &Credentials{
|
creds := &Credentials{
|
||||||
ServerURL: serverURL,
|
ServerURL: serverURL,
|
||||||
Username: "foo",
|
Username: "foo",
|
||||||
@@ -65,11 +65,11 @@ func TestStore(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.Username != "foo" {
|
if c.Username != "foo" {
|
||||||
t.Fatalf("expected username foo, got %s\n", c.Username)
|
t.Errorf("expected username foo, got %s\n", c.Username)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Secret != "bar" {
|
if c.Secret != "bar" {
|
||||||
t.Fatalf("expected username bar, got %s\n", c.Secret)
|
t.Errorf("expected username bar, got %s\n", c.Secret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ func TestStoreMissingServerURL(t *testing.T) {
|
|||||||
h := newMemoryStore()
|
h := newMemoryStore()
|
||||||
|
|
||||||
if err := Store(h, in); IsCredentialsMissingServerURL(err) == false {
|
if err := Store(h, in); IsCredentialsMissingServerURL(err) == false {
|
||||||
t.Fatal(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,12 +109,12 @@ func TestStoreMissingUsername(t *testing.T) {
|
|||||||
h := newMemoryStore()
|
h := newMemoryStore()
|
||||||
|
|
||||||
if err := Store(h, in); IsCredentialsMissingUsername(err) == false {
|
if err := Store(h, in); IsCredentialsMissingUsername(err) == false {
|
||||||
t.Fatal(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
serverURL := "https://index.docker.io/v1/"
|
const serverURL = "https://index.docker.io/v1/"
|
||||||
creds := &Credentials{
|
creds := &Credentials{
|
||||||
ServerURL: serverURL,
|
ServerURL: serverURL,
|
||||||
Username: "foo",
|
Username: "foo",
|
||||||
@@ -147,16 +147,16 @@ func TestGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.Username != "foo" {
|
if c.Username != "foo" {
|
||||||
t.Fatalf("expected username foo, got %s\n", c.Username)
|
t.Errorf("expected username foo, got %s\n", c.Username)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Secret != "bar" {
|
if c.Secret != "bar" {
|
||||||
t.Fatalf("expected username bar, got %s\n", c.Secret)
|
t.Errorf("expected username bar, got %s\n", c.Secret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetMissingServerURL(t *testing.T) {
|
func TestGetMissingServerURL(t *testing.T) {
|
||||||
serverURL := "https://index.docker.io/v1/"
|
const serverURL = "https://index.docker.io/v1/"
|
||||||
creds := &Credentials{
|
creds := &Credentials{
|
||||||
ServerURL: serverURL,
|
ServerURL: serverURL,
|
||||||
Username: "foo",
|
Username: "foo",
|
||||||
@@ -177,12 +177,12 @@ func TestGetMissingServerURL(t *testing.T) {
|
|||||||
w := new(bytes.Buffer)
|
w := new(bytes.Buffer)
|
||||||
|
|
||||||
if err := Get(h, buf, w); IsCredentialsMissingServerURL(err) == false {
|
if err := Get(h, buf, w); IsCredentialsMissingServerURL(err) == false {
|
||||||
t.Fatal(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestErase(t *testing.T) {
|
func TestErase(t *testing.T) {
|
||||||
serverURL := "https://index.docker.io/v1/"
|
const serverURL = "https://index.docker.io/v1/"
|
||||||
creds := &Credentials{
|
creds := &Credentials{
|
||||||
ServerURL: serverURL,
|
ServerURL: serverURL,
|
||||||
Username: "foo",
|
Username: "foo",
|
||||||
@@ -206,12 +206,12 @@ func TestErase(t *testing.T) {
|
|||||||
|
|
||||||
w := new(bytes.Buffer)
|
w := new(bytes.Buffer)
|
||||||
if err := Get(h, buf, w); err == nil {
|
if err := Get(h, buf, w); err == nil {
|
||||||
t.Fatal("expected error getting missing creds, got empty")
|
t.Error("expected error getting missing creds, got empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEraseMissingServerURL(t *testing.T) {
|
func TestEraseMissingServerURL(t *testing.T) {
|
||||||
serverURL := "https://index.docker.io/v1/"
|
const serverURL = "https://index.docker.io/v1/"
|
||||||
creds := &Credentials{
|
creds := &Credentials{
|
||||||
ServerURL: serverURL,
|
ServerURL: serverURL,
|
||||||
Username: "foo",
|
Username: "foo",
|
||||||
@@ -244,6 +244,6 @@ func TestList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// testing that there is an output
|
// testing that there is an output
|
||||||
if out.Len() == 0 {
|
if out.Len() == 0 {
|
||||||
t.Fatalf("expected output in the writer, got %d", 0)
|
t.Error("expected output in the writer, got 0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user