File: metadata_test.go

package info (click to toggle)
golang-github-smallstep-crypto 0.63.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,800 kB
  • sloc: sh: 66; makefile: 50
file content (43 lines) | stat: -rw-r--r-- 863 bytes parent folder | download
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package nssdb

import (
	"context"
	"database/sql"
	"testing"

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

func TestGetMetadata(t *testing.T) {
	ctx := context.Background()

	for _, v := range nssVersions {
		db := v.connect(t)

		t.Run(v.name("ok"), func(t *testing.T) {
			got, err := db.GetMetadata(ctx, "password")
			require.NoError(t, err)

			assert.Equal(t, "password", got.ID)
			assert.NotEmpty(t, got.Item1)
			assert.NotEmpty(t, got.Item2)
		})

		t.Run(v.name("not found"), func(t *testing.T) {
			_, err := db.GetMetadata(ctx, "notfound")
			assert.ErrorIs(t, err, sql.ErrNoRows)
		})
	}
}

func TestGetPassword(t *testing.T) {
	for _, v := range nssVersions {
		db := v.connect(t)

		t.Run(v.name("ok"), func(t *testing.T) {
			_, err := db.GetPassword(context.Background())
			require.NoError(t, err)
		})
	}
}