Skip to content

Commit

Permalink
Updated removed tags APIs to respond with 410 Gone
Browse files Browse the repository at this point in the history
  • Loading branch information
Xemdo committed Jul 13, 2023
1 parent 90b03e8 commit a86fa67
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 285 deletions.
16 changes: 14 additions & 2 deletions internal/mock_api/endpoints/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ func All() []mock_api.MockEndpoint {
schedule.ScheduleSettings{},
search.SearchCategories{},
search.SearchChannels{},
streams.AllTags{},
streams.FollowedStreams{},
streams.Markers{},
streams.StreamKey{},
streams.Streams{},
streams.StreamTags{},
subscriptions.BroadcasterSubscriptions{},
subscriptions.UserSubscriptions{},
teams.ChannelTeams{},
Expand All @@ -91,3 +89,17 @@ func All() []mock_api.MockEndpoint {
whispers.Whispers{},
}
}

// All these endpoints return 410 Gone
func Gone() map[string][]string {
return map[string][]string{
"/tags/streams": {
"GET",
},
"/streams/tags": {
"GET",
"POST",
"PUT",
},
}
}
98 changes: 0 additions & 98 deletions internal/mock_api/endpoints/streams/all_tags.go

This file was deleted.

127 changes: 0 additions & 127 deletions internal/mock_api/endpoints/streams/stream_tags.go

This file was deleted.

58 changes: 0 additions & 58 deletions internal/mock_api/endpoints/streams/streams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@ import (
"github.com/twitchdev/twitch-cli/test_setup/test_server"
)

func TestAllTags(t *testing.T) {
a := test_setup.SetupTestEnv(t)
ts := test_server.SetupTestServer(AllTags{})

// get
req, _ := http.NewRequest(http.MethodGet, ts.URL+AllTags{}.Path(), nil)
q := req.URL.Query()
req.URL.RawQuery = q.Encode()
resp, err := http.DefaultClient.Do(req)
a.Nil(err)
a.Equal(200, resp.StatusCode)

q.Set("tag_id", "1234")
req.URL.RawQuery = q.Encode()
resp, err = http.DefaultClient.Do(req)
a.Nil(err)
a.Equal(200, resp.StatusCode)
}

func TestFollowedStreams(t *testing.T) {
a := test_setup.SetupTestEnv(t)
ts := test_server.SetupTestServer(FollowedStreams{})
Expand Down Expand Up @@ -99,45 +80,6 @@ func TestMarkers(t *testing.T) {
a.Equal(400, resp.StatusCode)
}

func TestStreamTags(t *testing.T) {
a := test_setup.SetupTestEnv(t)
ts := test_server.SetupTestServer(StreamTags{})

// get
req, _ := http.NewRequest(http.MethodGet, ts.URL+StreamTags{}.Path(), nil)
q := req.URL.Query()
req.URL.RawQuery = q.Encode()
resp, err := http.DefaultClient.Do(req)
a.Nil(err)
a.Equal(401, resp.StatusCode)

q.Set("broadcaster_id", "1")
req.URL.RawQuery = q.Encode()
resp, err = http.DefaultClient.Do(req)
a.Nil(err)
a.Equal(200, resp.StatusCode)

// put
put := PutBodyStreamTags{
TagIDs: []string{"1234"},
}
b, _ := json.Marshal(put)
req, _ = http.NewRequest(http.MethodPut, ts.URL+StreamTags{}.Path(), bytes.NewBuffer(b))
q.Del("broadcaster_id")
req.URL.RawQuery = q.Encode()
resp, err = http.DefaultClient.Do(req)
a.Nil(err)
a.Equal(401, resp.StatusCode)

b, _ = json.Marshal(put)
req, _ = http.NewRequest(http.MethodPut, ts.URL+StreamTags{}.Path(), bytes.NewBuffer(b))
q.Set("broadcaster_id", "1")
req.URL.RawQuery = q.Encode()
resp, err = http.DefaultClient.Do(req)
a.Nil(err)
a.Equal(400, resp.StatusCode)
}

func TestStreamKey(t *testing.T) {
a := test_setup.SetupTestEnv(t)
ts := test_server.SetupTestServer(StreamKey{})
Expand Down
Loading

0 comments on commit a86fa67

Please sign in to comment.