This commit is contained in:
Jason Kulatunga
2020-08-19 16:04:21 -07:00
commit 8482272d45
336 changed files with 197309 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
package errors
import (
"fmt"
)
// Raised when config file is missing
type ConfigFileMissingError string
func (str ConfigFileMissingError) Error() string {
return fmt.Sprintf("ConfigFileMissingError: %q", string(str))
}
// Raised when the config file doesnt match schema
type ConfigValidationError string
func (str ConfigValidationError) Error() string {
return fmt.Sprintf("ConfigValidationError: %q", string(str))
}
// Raised when a dependency (like smartd or ssh-agent) is missing
type DependencyMissingError string
func (str DependencyMissingError) Error() string {
return fmt.Sprintf("DependencyMissingError: %q", string(str))
}
+34
View File
@@ -0,0 +1,34 @@
package errors_test
import (
"github.com/analogj/scrutiny/webapp/backend/pkg/errors"
"github.com/stretchr/testify/require"
"testing"
)
//func TestCheckErr_WithoutError(t *testing.T) {
// t.Parallel()
//
// //assert
// require.NotPanics(t, func() {
// errors.CheckErr(nil)
// })
//}
//func TestCheckErr_Error(t *testing.T) {
// t.Parallel()
//
// //assert
// require.Panics(t, func() {
// errors.CheckErr(stderrors.New("This is an error"))
// })
//}
func TestErrors(t *testing.T) {
t.Parallel()
//assert
require.Implements(t, (*error)(nil), errors.ConfigFileMissingError("test"), "should implement the error interface")
require.Implements(t, (*error)(nil), errors.ConfigValidationError("test"), "should implement the error interface")
require.Implements(t, (*error)(nil), errors.DependencyMissingError("test"), "should implement the error interface")
}