Initial commit
This commit is contained in:
74
error_test.go
Normal file
74
error_test.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package camfish
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestConfigError (test *testing.T) {
|
||||
err := ConfigError {
|
||||
File: "example.conf",
|
||||
Key: "some-key",
|
||||
Line: 6,
|
||||
Column: 20,
|
||||
Err: ErrNotFound,
|
||||
}
|
||||
str := err.Error()
|
||||
test.Log(str)
|
||||
if str != "example.conf[some-key]:6:20: not found" {
|
||||
test.Fatal("not equal")
|
||||
}
|
||||
unwrapped := err.Unwrap()
|
||||
test.Log(unwrapped)
|
||||
if unwrapped!= ErrNotFound {
|
||||
test.Fatal("not equal")
|
||||
}
|
||||
|
||||
err = ConfigError {
|
||||
File: "example.conf",
|
||||
Line: 6,
|
||||
Column: 20,
|
||||
Err: ErrNotFound,
|
||||
}
|
||||
str = err.Error()
|
||||
test.Log(str)
|
||||
if str != "example.conf:6:20: not found" {
|
||||
test.Fatal("not equal")
|
||||
}
|
||||
|
||||
err = ConfigError {
|
||||
Key: "some-key",
|
||||
Column: 20,
|
||||
Err: ErrNotFound,
|
||||
}
|
||||
str = err.Error()
|
||||
test.Log(str)
|
||||
if str != "[some-key]: not found" {
|
||||
test.Fatal("not equal")
|
||||
}
|
||||
|
||||
err = ConfigError {
|
||||
File: "example.conf",
|
||||
Key: "some-key",
|
||||
Line: 20,
|
||||
Err: ErrNotFound,
|
||||
}
|
||||
str = err.Error()
|
||||
test.Log(str)
|
||||
if str != "example.conf[some-key]:20: not found" {
|
||||
test.Fatal("not equal")
|
||||
}
|
||||
|
||||
err = ConfigError {
|
||||
Err: ErrNotFound,
|
||||
}
|
||||
str = err.Error()
|
||||
test.Log(str)
|
||||
if str != "not found" {
|
||||
test.Fatal("not equal")
|
||||
}
|
||||
|
||||
err = ConfigError { }
|
||||
str = err.Error()
|
||||
test.Log(str)
|
||||
if str != "configuration error" {
|
||||
test.Fatal("not equal")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user