File: db_test.go

package info (click to toggle)
golang-github-smallstep-certificates 0.28.4-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,684 kB
  • sloc: sh: 367; makefile: 129
file content (32 lines) | stat: -rw-r--r-- 758 bytes parent folder | download | duplicates (2)
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
package acme

import (
	"database/sql"
	"errors"
	"fmt"
	"testing"
)

func TestIsErrNotFound(t *testing.T) {
	type args struct {
		err error
	}
	tests := []struct {
		name string
		args args
		want bool
	}{
		{"true ErrNotFound", args{ErrNotFound}, true},
		{"true sql.ErrNoRows", args{sql.ErrNoRows}, true},
		{"true wrapped ErrNotFound", args{fmt.Errorf("something failed: %w", ErrNotFound)}, true},
		{"true wrapped sql.ErrNoRows", args{fmt.Errorf("something failed: %w", sql.ErrNoRows)}, true},
		{"false other", args{errors.New("not found")}, false},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := IsErrNotFound(tt.args.err); got != tt.want {
				t.Errorf("IsErrNotFound() = %v, want %v", got, tt.want)
			}
		})
	}
}