aboutsummaryrefslogtreecommitdiff
path: root/libpod/runtime_test.go
blob: 2e16c7fcd3f57095f687db30858d7281a135d687 (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
28
package libpod

import (
	"math/rand"
	"os"
	"testing"

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

func Test_generateName(t *testing.T) {
	state, path, _, err := getEmptyBoltState()
	assert.NoError(t, err)
	defer os.RemoveAll(path)
	defer state.Close()

	r := &Runtime{
		state: state,
	}

	// Test that (*Runtime).generateName returns different names
	// if called twice, even if the global RNG has the default
	// seed.
	n1, _ := r.generateName()
	rand.Seed(1)
	n2, _ := r.generateName()
	assert.NotEqual(t, n1, n2)
}