23 lines
472 B
Go
23 lines
472 B
Go
|
|
package radar
|
||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"apps/backend/internal/types"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestPutRadarScheduleReqJSON(t *testing.T) {
|
||
|
|
var req types.PutRadarScheduleReq
|
||
|
|
if err := json.Unmarshal([]byte(`{"hours":[6,18,21]}`), &req); err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
if len(req.Hours) != 3 || req.Hours[0] != 6 || req.Hours[2] != 21 {
|
||
|
|
t.Fatalf("hours=%v", req.Hours)
|
||
|
|
}
|
||
|
|
got := intHours(req.Hours)
|
||
|
|
if len(got) != 3 || got[1] != 18 {
|
||
|
|
t.Fatalf("intHours=%v", got)
|
||
|
|
}
|
||
|
|
}
|