mirror of
https://github.com/slackhq/nebula.git
synced 2024-11-14 20:05:53 +08:00
aba42f9fa6
* enforce the use of goimports Instead of enforcing `gofmt`, enforce `goimports`, which also asserts a separate section for non-builtin packages. * run `goimports` everywhere * exclude generated .pb.go files
44 lines
1 KiB
Go
44 lines
1 KiB
Go
package nebula
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestNewPunchyFromConfig(t *testing.T) {
|
|
c := NewConfig()
|
|
|
|
// Test defaults
|
|
p := NewPunchyFromConfig(c)
|
|
assert.Equal(t, false, p.Punch)
|
|
assert.Equal(t, false, p.Respond)
|
|
assert.Equal(t, time.Second, p.Delay)
|
|
|
|
// punchy deprecation
|
|
c.Settings["punchy"] = true
|
|
p = NewPunchyFromConfig(c)
|
|
assert.Equal(t, true, p.Punch)
|
|
|
|
// punchy.punch
|
|
c.Settings["punchy"] = map[interface{}]interface{}{"punch": true}
|
|
p = NewPunchyFromConfig(c)
|
|
assert.Equal(t, true, p.Punch)
|
|
|
|
// punch_back deprecation
|
|
c.Settings["punch_back"] = true
|
|
p = NewPunchyFromConfig(c)
|
|
assert.Equal(t, true, p.Respond)
|
|
|
|
// punchy.respond
|
|
c.Settings["punchy"] = map[interface{}]interface{}{"respond": true}
|
|
c.Settings["punch_back"] = false
|
|
p = NewPunchyFromConfig(c)
|
|
assert.Equal(t, true, p.Respond)
|
|
|
|
// punchy.delay
|
|
c.Settings["punchy"] = map[interface{}]interface{}{"delay": "1m"}
|
|
p = NewPunchyFromConfig(c)
|
|
assert.Equal(t, time.Minute, p.Delay)
|
|
}
|