Content-Length: 3870 | pFad | https://github.com/nicklaw5/helix/raw/refs/heads/main/entitlement_grants_test.go
th: 3857
package helix
import (
"context"
"net/http"
"strings"
"testing"
)
func TestCreateEntitlementsUploadURL(t *testing.T) {
t.Parallel()
testCases := []struct {
statusCode int
options *Options
manifestID string
entitlementType string
respBody string
expectedErrMsg string
}{
{
http.StatusUnauthorized,
&Options{
ClientID: "valid-client-id",
AppAccessToken: "invalid-app-access-token", // invalid app access token
},
"my-manifest-id",
"bulk_drops_grant",
`{"error":"Unauthorized","status":401,"message":"Must provide valid app token."}`,
"Must provide valid app token.",
},
{
http.StatusBadRequest,
&Options{
ClientID: "valid-client-id",
AppAccessToken: "valid-app-access-token",
},
"", // invalid manifest id
"bulk_drops_grant",
`{"error":"Bad Request","status":400,"message":"Missing required parameter \"manifest_id\""}`,
"Missing required parameter \"manifest_id\"",
},
{
http.StatusBadRequest,
&Options{
ClientID: "valid-client-id",
AppAccessToken: "valid-app-access-token",
},
"my-manifest-id",
"invalid_grant", // invalid entitlement type
`{"error":"Bad Request","status":400,"message":"The parameter \"type\" was malformed: value must be one of \"bulk_drops_grant\""}`,
"The parameter \"type\" was malformed: value must be one of \"bulk_drops_grant\"",
},
{
http.StatusOK,
&Options{
ClientID: "valid-client-id",
AppAccessToken: "valid-app-access-token",
},
"my-manifest-id",
"bulk_drops_grant",
`{"data":[{"url": "https://twitch-ds-vhs-drops-granted-uploads-us-west-2-prod.s3-us-west-2.amazonaws.com/valid-client-id/