package main

import (
	"flag"
	"testing"
)

func TestDefaultDisco(t *testing.T) {
	v := discoAliases[defaultDisco]
	if v == "" {
		t.Fatalf("alias for %q is zero; all aliases: %v", defaultDisco, discoAliases)
	}
}

func TestDiscoAliasFlag(t *testing.T) {
	tests := []struct {
		a    discoAliasFlag
		args []string
		want string
	}{
		{defaultDisco, []string{"-d", "letsencrypt-staging"}, discoAliases["letsencrypt-staging"]},
		{defaultDisco, []string{"-d", "https://disco"}, "https://disco"},
	}
	for i, test := range tests {
		var a = test.a
		fs := flag.NewFlagSet("test", flag.ContinueOnError)
		fs.Var(&a, "d", "")
		if err := fs.Parse(test.args); err != nil {
			t.Errorf("%d: parse(%v): %v", i, test.args, err)
			continue
		}
		if a.String() != test.want {
			t.Errorf("%d: a = %q; want %q", i, a, test.want)
		}
	}
}

package main

import (
	"flag"
	"testing"
)

func TestDefaultDisco(t *testing.T) {
	v := discoAliases[defaultDisco]
	if v == "" {
		t.Fatalf("alias for %q is zero; all aliases: %v", defaultDisco, discoAliases)
	}
}

func TestDiscoAliasFlag(t *testing.T) {
	tests := []struct {
		a    discoAliasFlag
		args []string
		want string
	}{
		{defaultDisco, []string{"-d", "letsencrypt-staging"}, discoAliases["letsencrypt-staging"]},
		{defaultDisco, []string{"-d", "https://disco"}, "https://disco"},
	}
	for i, test := range tests {
		var a discoAliasFlag = test.a
		fs := flag.NewFlagSet("test", flag.ContinueOnError)
		fs.Var(&a, "d", "")
		if err := fs.Parse(test.args); err != nil {
			t.Errorf("%d: parse(%v): %v", i, test.args, err)
			continue
		}
		if a.String() != test.want {
			t.Errorf("%d: a = %q; want %q", i, a, test.want)
		}
	}
}

--- 
+++ 
@@ -22,7 +22,7 @@
 		{defaultDisco, []string{"-d", "https://disco"}, "https://disco"},
 	}
 	for i, test := range tests {
-		var a discoAliasFlag = test.a
+		var a = test.a
 		fs := flag.NewFlagSet("test", flag.ContinueOnError)
 		fs.Var(&a, "d", "")
 		if err := fs.Parse(test.args); err != nil {
Fix golint using type in variable declaration

This fixes:

    main_test.go:25:9: should omit type discoAliasFlag from
    declaration of var a; it will be inferred from the right-hand side

Closes #29
