-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[enhance] using regex to detect error deleting server error
- Loading branch information
1 parent
def7f8a
commit 0dc856f
Showing
6 changed files
with
94 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package sdk_error | ||
|
||
import ( | ||
lregexp "regexp" | ||
"testing" | ||
) | ||
|
||
func TestRegex(t *testing.T) { | ||
regexErrorSubnetNotFound = lregexp.MustCompile(patternNotAllowDelete) | ||
patternServerCreating1 := "cannot delete server with status creating" // "Server is creating" | ||
patternServerCreatingBilling1 := "cannot delete server with status creating-billing" // "The number of servers exceeds the quota" | ||
patternServerDeleting1 := "cannot delete server with status deleting" | ||
patternFake := "cannot delete server with status fake" | ||
|
||
if regexErrorSubnetNotFound.FindString(patternServerCreating1) == "" { | ||
t.Errorf("patternServerCreating should match patternNotAllowDelete") | ||
} | ||
|
||
if regexErrorSubnetNotFound.FindString(patternServerCreatingBilling1) == "" { | ||
t.Errorf("patternServerCreatingBilling should match patternNotAllowDelete") | ||
} | ||
|
||
if regexErrorSubnetNotFound.FindString(patternServerDeleting1) == "" { | ||
t.Errorf("patternServerDeleting should match patternNotAllowDelete") | ||
} | ||
|
||
if regexErrorSubnetNotFound.FindString(patternFake) != "" { | ||
t.Errorf("patternFake should not match patternNotAllowDelete") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters