diff --git a/internal/edge/edge.go b/internal/edge/edge.go index 379c4094..da8ed143 100644 --- a/internal/edge/edge.go +++ b/internal/edge/edge.go @@ -19,14 +19,19 @@ type Client struct { token string } -func New(teamID string, token string, cookies []*http.Cookie) *Client { +func New(teamID string, token string, cookies []*http.Cookie) (*Client, error) { + cl, err := chttp.New("https://slack.com", cookies) + if err != nil { + return nil, err + } return &Client{ - cl: chttp.Must(chttp.New("https://slack.com", cookies)), + cl: cl, token: token, - apiPath: fmt.Sprintf("https://edgeapi.slack.com/cache/%s/", teamID)} + apiPath: fmt.Sprintf("https://edgeapi.slack.com/cache/%s/", teamID), + }, nil } -func NewWithProvider(teamID string, prov auth.Provider) *Client { +func NewWithProvider(teamID string, prov auth.Provider) (*Client, error) { return New(teamID, prov.SlackToken(), prov.Cookies()) } diff --git a/internal/edge/edge_test.go b/internal/edge/edge_test.go index 8f4ff798..2c18363d 100644 --- a/internal/edge/edge_test.go +++ b/internal/edge/edge_test.go @@ -25,11 +25,14 @@ func TestNew(t *testing.T) { t.Skip("test token not set") } - au, err := auth.NewValueAuth(testToken, testCookie) + prov, err := auth.NewValueAuth(testToken, testCookie) + if err != nil { + t.Fatal(err) + } + cl, err := New(testTeam, prov.SlackToken(), prov.Cookies()) if err != nil { t.Fatal(err) } - cl := New(testTeam, au.SlackToken(), au.Cookies()) req := UsersListRequest{ Channels: []string{"C6NL0QQSG"}, Filter: "everyone AND NOT bots AND NOT apps", @@ -54,7 +57,10 @@ func TestGetUsers(t *testing.T) { if err != nil { t.Fatal(err) } - cl := NewWithProvider(testTeam, au) + cl, err := NewWithProvider(testTeam, au) + if err != nil { + t.Fatal(err) + } ui, err := cl.GetUsers(context.Background(), []string{"U0LKLSNER", "U03K9GLS2", "U03KMNRQS"}) if err != nil { t.Fatal(err)