|
1 | 1 | package config |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "bytes" |
5 | 4 | "fmt" |
6 | 5 | "io/ioutil" |
7 | 6 | "strings" |
@@ -96,37 +95,3 @@ func TestReadingWritingConfig(t *testing.T) { |
96 | 95 | assert.Equal(t, c1.Dir, c2.Dir) |
97 | 96 | assert.Equal(t, c1.Hostname, c2.Hostname) |
98 | 97 | } |
99 | | - |
100 | | -func TestDecodingConfig(t *testing.T) { |
101 | | - unsanitizedJSON := `{"apiKey":"MyKey ","exercismDirectory":"/exercism/directory\r\n","hostname":"localhost \r\n"}` |
102 | | - c1 := &Config{ |
103 | | - APIKey: "MyKey", |
104 | | - Dir: "/exercism/directory", |
105 | | - Hostname: "localhost", |
106 | | - } |
107 | | - b := bytes.NewBufferString(unsanitizedJSON) |
108 | | - c2, err := Decode(b) |
109 | | - assert.NoError(t, err) |
110 | | - |
111 | | - assert.Equal(t, c1.APIKey, c2.APIKey) |
112 | | - assert.Equal(t, c1.Dir, c2.Dir) |
113 | | - assert.Equal(t, c1.Hostname, c2.Hostname) |
114 | | -} |
115 | | - |
116 | | -func TestEncodingConfig(t *testing.T) { |
117 | | - c := Config{ |
118 | | - APIKey: "MyKey ", |
119 | | - Dir: "/home/user name ", |
120 | | - Hostname: "localhost ", |
121 | | - ProblemsHost: " localhost:9292 ", |
122 | | - } |
123 | | - c.configure() |
124 | | - sanitizedJSON := `{"apiKey":"MyKey","exercismDirectory":"/home/user name","hostname":"localhost","problemsHost":"localhost:9292"} |
125 | | -` |
126 | | - |
127 | | - buf := new(bytes.Buffer) |
128 | | - err := c.Encode(buf) |
129 | | - |
130 | | - assert.NoError(t, err) |
131 | | - assert.Equal(t, sanitizedJSON, buf.String()) |
132 | | -} |
0 commit comments