File: application_config_test.go

package info (click to toggle)
coyim 0.3.7-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,064 kB
  • ctags: 4,528
  • sloc: xml: 5,120; sh: 328; python: 286; makefile: 235; ruby: 51
file content (38 lines) | stat: -rw-r--r-- 876 bytes parent folder | download
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
package config

import (
	. "gopkg.in/check.v1"
)

type AccountsSuite struct{}

var _ = Suite(&AccountsSuite{})

func (s *AccountsSuite) Test_Accounts_RemoveAccount(c *C) {
	ac1 := &Account{Account: "account@one.com"}
	ac2 := &Account{Account: "account@two.com"}
	acs := ApplicationConfig{
		Accounts: []*Account{ac1, ac2},
	}

	acs.Remove(ac1)

	c.Check(len(acs.Accounts), Equals, 1)
	_, found := acs.GetAccount("account@two.com")
	c.Check(found, Equals, true)
}

func (s *AccountsSuite) Test_Accounts_DontRemoveWhenDoesntExist(c *C) {
	ac1 := &Account{Account: "account@one.com"}
	ac2 := &Account{Account: "account@two.com"}
	ac3 := &Account{Account: "nohay@anywhere.com"}
	acs := ApplicationConfig{
		Accounts: []*Account{ac1, ac2},
	}

	acs.Remove(ac3)

	c.Check(len(acs.Accounts), Equals, 2)
	_, found := acs.GetAccount("account@two.com")
	c.Check(found, Equals, true)
}