Files
play-with-docker/pwd/session_test.go
Jonathan Leibiusky @xetorthio 911d56bc49 WIP
2017-05-19 17:25:05 -03:00

34 lines
637 B
Go

package pwd
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestNewSession_WithoutStack(t *testing.T) {
createdNetworkId := ""
mock := &mockDocker{}
mock.createNetwork = func(id string) error {
createdNetworkId = id
return nil
}
p := NewPWD(mock)
before := time.Now()
s, e := p.NewSession(time.Hour, "", "")
assert.Nil(t, e)
assert.NotNil(t, s)
assert.NotEmpty(t, s.Id)
assert.WithinDuration(t, s.CreatedAt, before, time.Since(before))
assert.WithinDuration(t, s.ExpiresAt, before.Add(time.Hour), time.Second)
assert.Equal(t, s.Id, createdNetworkId)
assert.NotNil(t, s.closingTimer)
}