Просмотр исходного кода

Merge pull request #159 from mirokuratczyk/master

Added coverage for missing SponsorId field in config test
Rod Hynes 10 лет назад
Родитель
Сommit
bbeaefbab9
2 измененных файлов с 17 добавлено и 6 удалено
  1. 9 0
      contributors/mirokuratczyk.md
  2. 8 6
      psiphon/config_test.go

+ 9 - 0
contributors/mirokuratczyk.md

@@ -0,0 +1,9 @@
+2016-03-31
+
+I hereby agree to the terms of the "Psiphon Individual Contributor License Agreement", with MD5 checksum 83d54c85a43e0c0f416758779ea6740a.
+
+I furthermore declare that I am authorized and able to make this agreement and sign this declaration.
+
+Signed,
+
+Miro Kuratczyk https://github.com/mirokuratczyk

+ 8 - 6
psiphon/config_test.go

@@ -86,12 +86,14 @@ func (suite *ConfigTestSuite) Test_LoadConfig_BadJson() {
 	_, err := LoadConfig([]byte(`{"f1": 11, "f2": "two"}`))
 	_, err := LoadConfig([]byte(`{"f1": 11, "f2": "two"}`))
 	suite.NotNil(err, "JSON with none of our fields should fail")
 	suite.NotNil(err, "JSON with none of our fields should fail")
 
 
-	// Missing a required field
-	json.Unmarshal(suite.confStubBlob, &testObj)
-	delete(testObj, suite.requiredFields[0])
-	testObjJSON, _ = json.Marshal(testObj)
-	_, err = LoadConfig(testObjJSON)
-	suite.NotNil(err, "JSON with one of our required fields missing should fail")
+	// Test config missing each required field
+	for i := range suite.requiredFields {
+	  json.Unmarshal(suite.confStubBlob, &testObj)
+	  delete(testObj, suite.requiredFields[i])
+	  testObjJSON, _ = json.Marshal(testObj)
+	  _, err = LoadConfig(testObjJSON)
+	  suite.NotNil(err, "JSON with one of our required fields missing should fail")
+	}
 
 
 	// Bad type for required field
 	// Bad type for required field
 	json.Unmarshal(suite.confStubBlob, &testObj)
 	json.Unmarshal(suite.confStubBlob, &testObj)