-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathhelpers_test.go
More file actions
50 lines (40 loc) · 1.42 KB
/
helpers_test.go
File metadata and controls
50 lines (40 loc) · 1.42 KB
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
44
45
46
47
48
49
50
// Copyright IBM Corp. 2020, 2025
// SPDX-License-Identifier: MPL-2.0
package openldap
import (
"context"
"testing"
"github.com/hashicorp/vault/sdk/logical"
"github.com/stretchr/testify/require"
)
func assertNoError(t *testing.T, resp *logical.Response, err error) {
t.Helper()
require.NoError(t, err)
require.Nil(t, resp.Error())
}
func pathOperation(t *testing.T, b *backend, s logical.Storage, path string, d map[string]interface{}, o logical.Operation) (*logical.Response, error) {
t.Helper()
req := &logical.Request{
Operation: o,
Path: path,
Storage: s,
Data: d,
}
return b.HandleRequest(context.Background(), req)
}
func testCreateConfigWithData(t *testing.T, b *backend, s logical.Storage, d map[string]interface{}) (*logical.Response, error) {
t.Helper()
return pathOperation(t, b, s, configPath, d, logical.CreateOperation)
}
func testUpdateConfigWithData(t *testing.T, b *backend, s logical.Storage, d map[string]interface{}) (*logical.Response, error) {
t.Helper()
return pathOperation(t, b, s, configPath, d, logical.UpdateOperation)
}
func testReadConfig(t *testing.T, b *backend, s logical.Storage) (*logical.Response, error) {
t.Helper()
return pathOperation(t, b, s, configPath, nil, logical.ReadOperation)
}
func testDeleteConfig(t *testing.T, b *backend, s logical.Storage) (*logical.Response, error) {
t.Helper()
return pathOperation(t, b, s, configPath, nil, logical.DeleteOperation)
}