-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource_create_test.go
More file actions
64 lines (56 loc) · 1.55 KB
/
source_create_test.go
File metadata and controls
64 lines (56 loc) · 1.55 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package unstructured
import (
"errors"
"net/http"
"testing"
"time"
)
func TestCreateSource(t *testing.T) {
t.Parallel()
client, mux := testclient(t)
mux.CreateSource = func(w http.ResponseWriter, _ *http.Request) {
response := []byte(`{` +
` "config": {` +
` "client_id": "foo",` +
` "tenant": "foo",` +
` "authority_url": "foo",` +
` "user_pname": "foo",` +
` "client_cred": "foo",` +
` "recursive": false,` +
` "path": "foo"` +
` },` +
` "created_at": "2023-09-15T01:06:53.146Z",` +
` "id": "a15d4161-77a0-4e08-b65e-86f398ce15ad",` +
` "name": "test_source_name",` +
` "type": "onedrive"` +
`}`)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(response)
}
source, err := client.CreateSource(testContext(t), CreateSourceRequest{
Name: "test_source_name",
Config: &OneDriveConnectorConfig{
ClientID: "foo",
Tenant: "foo",
AuthorityURL: "foo",
UserPName: "foo",
ClientCred: "foo",
Path: String("foo"),
},
})
if err != nil {
t.Fatalf("failed to create source: %v", err)
}
if err := errors.Join(
eq("source.id", source.ID, "a15d4161-77a0-4e08-b65e-86f398ce15ad"),
eq("source.name", source.Name, "test_source_name"),
equal("source.created_at", source.CreatedAt, time.Date(2023, 9, 15, 1, 6, 53, 146000000, time.UTC)),
); err != nil {
t.Error(err)
}
cfg, ok := source.Config.(*OneDriveConnectorConfig)
if !ok {
t.Errorf("expected source config to be %T, got %T", cfg, source.Config)
}
}