Debian Codegraph @

attachments_test.go

raw symbols SCIP
1 package slackscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/
2
3 import (
4 "encoding/jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/"
5 "stringsscip-go gomod github.com/golang/go/src go1.16 strings/"
6 "testingscip-go gomod github.com/golang/go/src go1.16 testing/"
7
8 "github.com/go-test/deepscip-go gomod github.com/go-test/deep v1.0.4 `github.com/go-test/deep`/"
9 )
10
11 func TestAttachment_UnmarshalMarshalJSON_WithBlocksscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/TestAttachment_UnmarshalMarshalJSON_WithBlocks().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
12
13 originalAttachmentJson := `{
14 "id": 1,
15 "blocks": [
16 {
17 "type": "section",
18 "block_id": "xxxx",
19 "text": {
20 "type": "mrkdwn",
21 "text": "Pick something:",
22 "verbatim": true
23 },
24 "accessory": {
25 "type": "static_select",
26 "action_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
27 "placeholder": {
28 "type": "plain_text",
29 "text": "Select one item",
30 "emoji": true
31 },
32 "options": [
33 {
34 "text": {
35 "type": "plain_text",
36 "text": "ghi",
37 "emoji": true
38 },
39 "value": "ghi"
40 }
41 ]
42 }
43 }
44 ],
45 "color": "#13A554",
46 "fallback": "[no preview available]"
47 }`
48
49 attachment := new(Attachmentscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Attachment#)
50 err := jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Unmarshal().([]byte(originalAttachmentJson), attachment)
51 if err != nil {
52 t.Fatalfscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatalf().("expected no error unmarshaling attachment with blocks, got: %v", err)
53 }
54
55 actualAttachmentJson, err := jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Marshal().(attachment)
56 if err != nil {
57 t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().(err)
58 }
59
60 var (
61 actual interface{}
62 expected interface{}
63 )
64 if err = jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Unmarshal().([]byte(originalAttachmentJson), &expected); err != nil {
65 t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().(err)
66 }
67 if err = jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Unmarshal().(actualAttachmentJson, &actual); err != nil {
68 t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().(err)
69 }
70 if diff := deepscip-go gomod github.com/go-test/deep v1.0.4 `github.com/go-test/deep`/.Equalscip-go gomod github.com/go-test/deep v1.0.4 `github.com/go-test/deep`/Equal().(actual, expected); diff != nil {
71 t.Fatalscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatal().("actual does not match expected\n", stringsscip-go gomod github.com/golang/go/src go1.16 strings/.Joinscip-go gomod github.com/golang/go/src go1.16 strings/Join().(diff, "\n"))
72 }
73 }