File: tokens_test.go

package info (click to toggle)
snowflake 2.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,104 kB
  • sloc: makefile: 5
file content (28 lines) | stat: -rw-r--r-- 575 bytes parent folder | download | duplicates (2)
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
package snowflake_proxy

import (
	"testing"

	. "github.com/smartystreets/goconvey/convey"
)

func TestTokens(t *testing.T) {
	Convey("Tokens", t, func() {
		tokens := newTokens(2)
		So(tokens.count(), ShouldEqual, 0)
		tokens.get()
		So(tokens.count(), ShouldEqual, 1)
		tokens.ret()
		So(tokens.count(), ShouldEqual, 0)
	})
	Convey("Tokens capacity 0", t, func() {
		tokens := newTokens(0)
		So(tokens.count(), ShouldEqual, 0)
		for i := 0; i < 20; i++ {
			tokens.get()
		}
		So(tokens.count(), ShouldEqual, 20)
		tokens.ret()
		So(tokens.count(), ShouldEqual, 19)
	})
}