| 1 | package slackscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/httpscip-go gomod github.com/golang/go/src go1.16 `net/http`/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.16 testing/" |
| 6 | ) |
| 7 | |
| 8 | func getBotInfoscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/getBotInfo().(rw httpscip-go gomod github.com/golang/go/src go1.16 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.16 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.16 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.16 `net/http`/Request#) { |
| 9 | rw.Headerscip-go gomod github.com/golang/go/src go1.16 `net/http`/ResponseWriter#Header().().Setscip-go gomod github.com/golang/go/src go1.16 `net/http`/Header#Set().("Content-Type", "application/json") |
| 10 | response := []byte(`{"ok": true, "bot": { |
| 11 | "id":"B02875YLA", |
| 12 | "deleted":false, |
| 13 | "name":"github", |
| 14 | "updated": 1449272004, |
| 15 | "app_id":"A161CLERW", |
| 16 | "user_id": "U012ABCDEF", |
| 17 | "icons": { |
| 18 | "image_36":"https:\/\/a.slack-edge.com\/2fac\/plugins\/github\/assets\/service_36.png", |
| 19 | "image_48":"https:\/\/a.slack-edge.com\/2fac\/plugins\/github\/assets\/service_48.png", |
| 20 | "image_72":"https:\/\/a.slack-edge.com\/2fac\/plugins\/github\/assets\/service_72.png" |
| 21 | } |
| 22 | }}`) |
| 23 | rw.Writescip-go gomod github.com/golang/go/src go1.16 `net/http`/ResponseWriter#Write().(response) |
| 24 | } |
| 25 | |
| 26 | func TestGetBotInfoscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/TestGetBotInfo().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) { |
| 27 | httpscip-go gomod github.com/golang/go/src go1.16 `net/http`/.HandleFuncscip-go gomod github.com/golang/go/src go1.16 `net/http`/HandleFunc().("/bots.info", getBotInfoscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/getBotInfo().) |
| 28 | |
| 29 | oncescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/once..Doscip-go gomod github.com/golang/go/src go1.16 sync/Once#Do().(startServerscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/startServer().) |
| 30 | api := Newscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/New().("testing-token", OptionAPIURLscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/OptionAPIURL().("http://"+serverAddrscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/serverAddr.+"/")) |
| 31 | |
| 32 | bot, err := api.GetBotInfoscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Client#GetBotInfo().("B02875YLA") |
| 33 | if err != nil { |
| 34 | t.Errorfscip-go gomod github.com/golang/go/src go1.16 testing/common#Errorf().("Unexpected error: %s", err) |
| 35 | return |
| 36 | } |
| 37 | |
| 38 | if bot.IDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Bot#ID. != "B02875YLA" { |
| 39 | t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("Incorrect ID") |
| 40 | } |
| 41 | if bot.Namescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Bot#Name. != "github" { |
| 42 | t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("Incorrect Name") |
| 43 | } |
| 44 | if bot.Deletedscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Bot#Deleted. { |
| 45 | t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("Incorrect Deleted flag") |
| 46 | } |
| 47 | if bot.AppIDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Bot#AppID. != "A161CLERW" { |
| 48 | t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("Incorrect App ID") |
| 49 | } |
| 50 | if bot.UserIDscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Bot#UserID. != "U012ABCDEF" { |
| 51 | t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("Incorrect User ID") |
| 52 | } |
| 53 | if bot.Updatedscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Bot#Updated. != 1449272004 { |
| 54 | t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("Incorrect Updated") |
| 55 | } |
| 56 | if len(bot.Iconsscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Bot#Icons..Image36scip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Icons#Image36.) == 0 { |
| 57 | t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("Missing Image36") |
| 58 | } |
| 59 | if len(bot.Iconsscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Bot#Icons..Image48scip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Icons#Image48.) == 0 { |
| 60 | t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("Missing Image38") |
| 61 | } |
| 62 | if len(bot.Iconsscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Bot#Icons..Image72scip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Icons#Image72.) == 0 { |
| 63 | t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("Missing Image72") |
| 64 | } |
| 65 | } |