app-cloudep-member-server/internal/lib/snackflow/error_test.go

55 lines
987 B
Go

package snowflake
import (
"fmt"
"testing"
"time"
)
func TestNewNodeError_Error(t *testing.T) {
startTime, err := time.Parse(time.DateOnly, "2023-07-20")
if err != nil {
t.Error(err)
}
t.Parallel()
type fields struct {
machineNodeID int64
startTime time.Time
Err error
}
tests := []struct {
name string
fields fields
want string
}{
{
name: "success",
fields: fields{
machineNodeID: 1,
startTime: startTime,
Err: nil,
},
want: fmt.Sprintf("new node fail machineNodeID: %d, startTime: %s, err: %v",
1, "2023-07-20 00:00:00 +0000 UTC", nil),
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
e := &NewNodeError{
machineNodeID: tt.fields.machineNodeID,
startTime: tt.fields.startTime,
Err: tt.fields.Err,
}
if got := e.Error(); got != tt.want {
t.Errorf("Error() = %v, want %v", got, tt.want)
}
})
}
}