@@ -46,10 +46,6 @@ func TestMuteTimings(t *testing.T) {
4646 t .Run ("get non-existent mute timing fails" , func (t * testing.T ) {
4747 server , client := gapiTestTools (t , 404 , muteTimingJSON )
4848 defer server .Close ()
49- /*cfg := Config{
50- BasicAuth: url.UserPassword("admin", "admin"),
51- }
52- client, _ := New("http://localhost:3000", cfg)*/
5349
5450 mt , err := client .MuteTiming ("does not exist" )
5551
@@ -58,6 +54,55 @@ func TestMuteTimings(t *testing.T) {
5854 t .Log (pretty .PrettyFormat (mt ))
5955 }
6056 })
57+
58+ t .Run ("create mute timing succeeds" , func (t * testing.T ) {
59+ server , client := gapiTestTools (t , 201 , muteTimingJSON )
60+ defer server .Close ()
61+ mt := createMuteTiming ()
62+
63+ err := client .NewMuteTiming (& mt )
64+
65+ if err != nil {
66+ t .Error (err )
67+ }
68+ })
69+
70+ t .Run ("update mute timing succeeds" , func (t * testing.T ) {
71+ server , client := gapiTestTools (t , 200 , muteTimingJSON )
72+ defer server .Close ()
73+ mt := createMuteTiming ()
74+ mt .TimeIntervals [0 ].Weekdays = []WeekdayRange {"tuesday" , "thursday" }
75+
76+ err := client .UpdateMuteTiming (& mt )
77+
78+ if err != nil {
79+ t .Error (err )
80+ }
81+ })
82+
83+ t .Run ("delete mute timing succeeds" , func (t * testing.T ) {
84+ server , client := gapiTestTools (t , 204 , muteTimingJSON )
85+ defer server .Close ()
86+
87+ err := client .DeleteMuteTiming ("timing two" )
88+
89+ if err != nil {
90+ t .Error (err )
91+ }
92+ })
93+ }
94+
95+ func createMuteTiming () MuteTiming {
96+ return MuteTiming {
97+ Name : "timing two" ,
98+ TimeIntervals : []TimeInterval {
99+ {
100+ Weekdays : []WeekdayRange {"monday" , "wednesday" },
101+ Months : []MonthRange {"1:3" , "4" },
102+ Years : []YearRange {"2022" , "2023" },
103+ },
104+ },
105+ }
61106}
62107
63108const getMuteTimingsJSON = `
0 commit comments