1234567891011121314151617181920 |
- package main
- import (
- "fmt"
- "testing"
- )
- func TestDbParseString(t *testing.T) {
- expected_message := "duplicate entry"
- expected_code := int64(1062)
- error_string := fmt.Sprintf("Error %d: %s", expected_code, expected_message)
- actual_message, actual_code := dbParseEror(error_string)
- if actual_message != expected_message {
- t.Errorf("Message: expected [%s], got [%s].\n", expected_message, actual_message)
- }
- if actual_code != expected_code {
- t.Errorf("Code: expected %d, got %d.\n", expected_code, actual_code)
- }
- }
|