From ed91395f201a6a8d167e856ed3958f1901508934 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 27 May 2023 14:18:56 +0200 Subject: [PATCH] wincred: don't use un-keyed literals in test-tables Also moving the comments into the test-tables. Signed-off-by: Sebastiaan van Stijn --- wincred/wincred_windows_test.go | 74 ++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/wincred/wincred_windows_test.go b/wincred/wincred_windows_test.go index 074b29c..27a12a9 100644 --- a/wincred/wincred_windows_test.go +++ b/wincred/wincred_windows_test.go @@ -91,17 +91,25 @@ func TestWinCredHelper(t *testing.T) { // through variations on the URL func TestWinCredHelperRetrieveAliases(t *testing.T) { tests := []struct { + doc string storeURL string readURL string }{ - // stored with port, retrieved without - {"https://foobar.docker.io:2376", "https://foobar.docker.io"}, - - // stored as https, retrieved without scheme - {"https://foobar.docker.io", "foobar.docker.io"}, - - // stored with path, retrieved without - {"https://foobar.docker.io/one/two", "https://foobar.docker.io"}, + { + doc: "stored with port, retrieved without", + storeURL: "https://foobar.docker.io:2376", + readURL: "https://foobar.docker.io", + }, + { + doc: "stored as https, retrieved without scheme", + storeURL: "https://foobar.docker.io", + readURL: "foobar.docker.io", + }, + { + doc: "stored with path, retrieved without", + storeURL: "https://foobar.docker.io/one/two", + readURL: "https://foobar.docker.io", + }, } helper := Wincred{} @@ -133,26 +141,42 @@ func TestWinCredHelperRetrieveAliases(t *testing.T) { // returned. func TestWinCredHelperRetrieveStrict(t *testing.T) { tests := []struct { + doc string storeURL string readURL string }{ - // stored as https, retrieved using http - {"https://foobar.docker.io:2376", "http://foobar.docker.io:2376"}, - - // stored as http, retrieved using https - {"http://foobar.docker.io:2376", "https://foobar.docker.io:2376"}, - - // same: stored as http, retrieved without a scheme specified (hence, using the default https://) - {"http://foobar.docker.io", "foobar.docker.io:5678"}, - - // non-matching ports - {"https://foobar.docker.io:1234", "https://foobar.docker.io:5678"}, - - // non-matching ports TODO is this desired behavior? The other way round does work - // {"https://foobar.docker.io", "https://foobar.docker.io:5678"}, - - // non-matching paths - {"https://foobar.docker.io:1234/one/two", "https://foobar.docker.io:1234/five/six"}, + { + doc: "stored as https, retrieved using http", + storeURL: "https://foobar.docker.io:2376", + readURL: "http://foobar.docker.io:2376", + }, + { + doc: "stored as http, retrieved using https", + storeURL: "http://foobar.docker.io:2376", + readURL: "https://foobar.docker.io:2376", + }, + { + // stored as http, retrieved without a scheme specified (hence, using the default https://) + doc: "stored as http, retrieved without scheme", + storeURL: "http://foobar.docker.io", + readURL: "foobar.docker.io:5678", + }, + { + doc: "non-matching ports", + storeURL: "https://foobar.docker.io:1234", + readURL: "https://foobar.docker.io:5678", + }, + // TODO: is this desired behavior? The other way round does work + // { + // doc: "non-matching ports (stored without port)", + // storeURL: "https://foobar.docker.io", + // readURL: "https://foobar.docker.io:5678", + // }, + { + doc: "non-matching paths", + storeURL: "https://foobar.docker.io:1234/one/two", + readURL: "https://foobar.docker.io:1234/five/six", + }, } helper := Wincred{}