summaryrefslogtreecommitdiff
path: root/internal/state_test.go
blob: bdb0582585c478dcd3c4286c1243f326e7eddbc5 (plain)
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
package internal

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func Test_NewState(t *testing.T) {
	st := NewWorkerState(StateErrored)

	assert.Equal(t, "errored", st.String())

	assert.Equal(t, "inactive", NewWorkerState(StateInactive).String())
	assert.Equal(t, "ready", NewWorkerState(StateReady).String())
	assert.Equal(t, "working", NewWorkerState(StateWorking).String())
	assert.Equal(t, "stopped", NewWorkerState(StateStopped).String())
	assert.Equal(t, "undefined", NewWorkerState(1000).String())
}

func Test_IsActive(t *testing.T) {
	assert.False(t, NewWorkerState(StateInactive).IsActive())
	assert.True(t, NewWorkerState(StateReady).IsActive())
	assert.True(t, NewWorkerState(StateWorking).IsActive())
	assert.False(t, NewWorkerState(StateStopped).IsActive())
	assert.False(t, NewWorkerState(StateErrored).IsActive())
}