@@ -26,11 +26,13 @@ func TestCustomValues(t *testing.T) {
2626 APIKey : "abc123" ,
2727 API : "http://example.org" ,
2828 Dir : "/path/to/exercises" ,
29+ XAPI : "http://x.example.org" ,
2930 }
3031 c .configure ()
3132 assert .Equal (t , "abc123" , c .APIKey )
3233 assert .Equal (t , "http://example.org" , c .API )
3334 assert .Equal (t , "/path/to/exercises" , c .Dir )
35+ assert .Equal (t , "http://x.example.org" , c .XAPI )
3436}
3537
3638func TestExpandHomeDir (t * testing.T ) {
@@ -45,11 +47,13 @@ func TestSanitizeWhitespace(t *testing.T) {
4547 APIKey : " abc123\n \r \n " ,
4648 API : " " ,
4749 Dir : " \r \n /path/to/exercises \r \n " ,
50+ XAPI : " " ,
4851 }
4952 c .configure ()
5053 assert .Equal (t , "abc123" , c .APIKey )
5154 assert .Equal (t , "http://exercism.io" , c .API )
5255 assert .Equal (t , "/path/to/exercises" , c .Dir )
56+ assert .Equal (t , "http://x.exercism.io" , c .XAPI )
5357}
5458
5559func TestFilePath (t * testing.T ) {
@@ -71,6 +75,7 @@ func TestReadNonexistantConfig(t *testing.T) {
7175 assert .NoError (t , err )
7276 assert .Equal (t , c .APIKey , "" )
7377 assert .Equal (t , c .API , "http://exercism.io" )
78+ assert .Equal (t , c .XAPI , "http://x.exercism.io" )
7479 assert .False (t , c .IsAuthenticated ())
7580 if ! strings .HasSuffix (c .Dir , filepath .FromSlash ("/exercism" )) {
7681 t .Fatal ("Default unconfigured config should use home dir" )
@@ -86,6 +91,7 @@ func TestReadingWritingConfig(t *testing.T) {
8691 APIKey : "MyKey" ,
8792 Dir : "/exercism/directory" ,
8893 API : "localhost" ,
94+ XAPI : "localhost" ,
8995 }
9096 c1 .configure ()
9197
@@ -98,29 +104,40 @@ func TestReadingWritingConfig(t *testing.T) {
98104 assert .Equal (t , c1 .APIKey , c2 .APIKey )
99105 assert .Equal (t , c1 .Dir , c2 .Dir )
100106 assert .Equal (t , c1 .API , c2 .API )
107+ assert .Equal (t , c1 .XAPI , c2 .XAPI )
101108}
102109
103110func TestUpdateConfig (t * testing.T ) {
104111 c := & Config {
105112 APIKey : "MyKey" ,
106113 Dir : "/exercism/directory" ,
107114 API : "localhost" ,
115+ XAPI : "localhost" ,
108116 }
109117
110- c .Update ("NewKey" , "" , "" )
118+ c .Update ("NewKey" , "" , "" , "" )
111119 assert .Equal (t , "NewKey" , c .APIKey )
112120 assert .Equal (t , "localhost" , c .API )
113121 assert .Equal (t , "/exercism/directory" , c .Dir )
122+ assert .Equal (t , "localhost" , c .XAPI )
114123
115- c .Update ("" , "http://example.com" , "" )
124+ c .Update ("" , "http://example.com" , "" , "" )
116125 assert .Equal (t , "NewKey" , c .APIKey )
117126 assert .Equal (t , "http://example.com" , c .API )
118127 assert .Equal (t , "/exercism/directory" , c .Dir )
128+ assert .Equal (t , "localhost" , c .XAPI )
129+
130+ c .Update ("" , "" , "/tmp/exercism" , "" )
131+ assert .Equal (t , "NewKey" , c .APIKey )
132+ assert .Equal (t , "http://example.com" , c .API )
133+ assert .Equal (t , "/tmp/exercism" , c .Dir )
134+ assert .Equal (t , "localhost" , c .XAPI )
119135
120- c .Update ("" , "" , "/tmp/exercism " )
136+ c .Update ("" , "" , "" , "http://x.example.org " )
121137 assert .Equal (t , "NewKey" , c .APIKey )
122138 assert .Equal (t , "http://example.com" , c .API )
123139 assert .Equal (t , "/tmp/exercism" , c .Dir )
140+ assert .Equal (t , "http://x.example.org" , c .XAPI )
124141}
125142
126143func TestReadDefaultConfig (t * testing.T ) {
0 commit comments