-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathactivationresponse_test.go
61 lines (48 loc) · 2.26 KB
/
activationresponse_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package scopes_test
import (
. "gopkg.in/check.v1"
"launchpad.net/go-unityscopes/v2"
)
func (s *S) TestActivationResponse(c *C) {
// check all different status
response := scopes.NewActivationResponse(scopes.ActivationNotHandled)
c.Check(response.Status, Equals, scopes.ActivationNotHandled)
c.Check(response.Query, IsNil)
c.Check(response.ScopeData, IsNil)
response = scopes.NewActivationResponse(scopes.ActivationShowDash)
c.Check(response.Status, Equals, scopes.ActivationShowDash)
c.Check(response.Query, IsNil)
c.Check(response.ScopeData, IsNil)
response = scopes.NewActivationResponse(scopes.ActivationShowDash)
c.Check(response.Status, Equals, scopes.ActivationShowDash)
c.Check(response.Query, IsNil)
c.Check(response.ScopeData, IsNil)
// we should get panic with ActivationPerformQuery
c.Check(func() { scopes.NewActivationResponse(scopes.ActivationPerformQuery) }, PanicMatches, "Use NewActivationResponseFromQuery for PerformQuery responses")
// test SetScopeData
response.SetScopeData("test_string")
c.Check(response.ScopeData, Equals, "test_string")
response.SetScopeData(1999)
c.Check(response.ScopeData, Equals, 1999)
response.SetScopeData(1.999)
c.Check(response.ScopeData, Equals, 1.999)
response.SetScopeData([]string{"test1", "test2"})
c.Check(response.ScopeData, DeepEquals, []string{"test1", "test2"})
// test activation response for query
query := scopes.NewCannedQuery("scope", "query_string", "department_string")
response_query := scopes.NewActivationResponseForQuery(query)
c.Check(response_query.Status, Equals, scopes.ActivationPerformQuery)
c.Check(response_query.Query, Equals, query)
c.Check(response_query.ScopeData, IsNil)
// test activation response for reply
result := scopes.NewTestingResult()
response = scopes.NewActivationResponseUpdateResult(result)
c.Check(response.Status, Equals, scopes.ActivationUpdateResult)
c.Check(response.Result, Equals, result)
// test activation response for a preview update
widget1 := scopes.NewPreviewWidget("id1", "text")
widget2 := scopes.NewPreviewWidget("id2", "image")
response = scopes.NewActivationResponseUpdatePreview(widget1, widget2)
c.Check(response.Status, Equals, scopes.ActivationUpdatePreview)
c.Check(response.Widgets, DeepEquals, []scopes.PreviewWidget{widget1, widget2})
}