@@ -30,7 +30,7 @@ func TestNewConfigCommand(t *testing.T) {
3030 assert .Assert (t , err .Error () == "Failed to set property: unknown property or bad value" )
3131}
3232
33- func TestGetConfigFilePath (t * testing.T ) {
33+ func TestGetConfigFilePath_CheckmarxConfigFileExists_Success (t * testing.T ) {
3434 want := ".checkmarx/checkmarxcli.yaml"
3535 got , err := configuration .GetConfigFilePath ()
3636
@@ -42,21 +42,25 @@ func TestGetConfigFilePath(t *testing.T) {
4242 asserts .True (t , strings .HasSuffix (got , want ), "Expected config file path to end with %q, but got %q" , want , got )
4343}
4444
45- func TestWriteSingleConfigKeyToExistingFile (t * testing.T ) {
45+ func TestWriteSingleConfigKeyToExistingFile_ChangeAscaPortToZero_Success (t * testing.T ) {
4646 configuration .LoadConfiguration ()
4747 configFilePath , _ := configuration .GetConfigFilePath ()
48- err := configuration .WriteSingleConfigKey (configFilePath , cxAscaPort , 0 )
48+ err := configuration .SafeWriteSingleConfigKey (configFilePath , cxAscaPort , 0 )
4949 assert .NilError (t , err )
50+
51+ config , err := configuration .LoadConfig (configFilePath )
52+ assert .NilError (t , err )
53+ asserts .Equal (t , 0 , config [cxAscaPort ])
5054}
5155
52- func TestWriteSingleConfigKeyToNonExistingFile (t * testing.T ) {
56+ func TestWriteSingleConfigKeyNonExistingFile_CreatingTheFileAndWritesTheKey_Success (t * testing.T ) {
5357 configFilePath := "non-existing-file"
5458
5559 file , err := os .Open (configFilePath )
5660 asserts .NotNil (t , err )
5761 asserts .Nil (t , file )
5862
59- err = configuration .WriteSingleConfigKey (configFilePath , cxAscaPort , 0 )
63+ err = configuration .SafeWriteSingleConfigKey (configFilePath , cxAscaPort , 0 )
6064 assert .NilError (t , err )
6165
6266 file , err = os .Open (configFilePath )
@@ -69,14 +73,14 @@ func TestWriteSingleConfigKeyToNonExistingFile(t *testing.T) {
6973 asserts .NotNil (t , file )
7074}
7175
72- func TestChangedOnlyAscaPortInConfigFile (t * testing.T ) {
76+ func TestChangedOnlyAscaPortInConfigFile_ConfigFileExistsWithDefaultValues_OnlyAscaPortChangedSuccess (t * testing.T ) {
7377 configuration .LoadConfiguration ()
7478 configFilePath , _ := configuration .GetConfigFilePath ()
7579
7680 oldConfig , err := configuration .LoadConfig (configFilePath )
7781 assert .NilError (t , err )
7882
79- err = configuration .WriteSingleConfigKey (configFilePath , cxAscaPort , - 1 )
83+ err = configuration .SafeWriteSingleConfigKey (configFilePath , cxAscaPort , - 1 )
8084 assert .NilError (t , err )
8185
8286 config , err := configuration .LoadConfig (configFilePath )
0 commit comments