-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrive_example_test.go
More file actions
58 lines (51 loc) · 1.63 KB
/
drive_example_test.go
File metadata and controls
58 lines (51 loc) · 1.63 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
package core_test
import (
. "dappco.re/go"
)
// ExampleDriveHandle defines drive handle metadata through `DriveHandle` for remote drive
// metadata. Drive handles carry names and transports before remote API calls use them.
func ExampleDriveHandle() {
handle := DriveHandle{Name: "forge", Transport: "https://forge.example"}
Println(handle.Name)
Println(handle.Transport)
// Output:
// forge
// https://forge.example
}
// ExampleDrive reaches drive registration through `Drive` for remote drive metadata. Drive
// handles carry names and transports before remote API calls use them.
func ExampleDrive() {
d := &Drive{Registry: NewRegistry[*DriveHandle]()}
d.New(NewOptions(Option{Key: "name", Value: "forge"}))
Println(d.Names())
// Output: [forge]
}
// ExampleDrive_New registers a remote drive handle from name and transport options. Drive
// handles carry names and transports before remote API calls use them.
func ExampleDrive_New() {
c := New()
c.Drive().New(NewOptions(
Option{Key: "name", Value: "forge"},
Option{Key: "transport", Value: "https://forge.lthn.ai"},
))
Println(c.Drive().Has("forge"))
Println(c.Drive().Names())
// Output:
// true
// [forge]
}
// ExampleDrive_Get retrieves a value through `Drive.Get` for remote drive metadata. Drive
// handles carry names and transports before remote API calls use them.
func ExampleDrive_Get() {
c := New()
c.Drive().New(NewOptions(
Option{Key: "name", Value: "charon"},
Option{Key: "transport", Value: "http://10.69.69.165:9101"},
))
r := c.Drive().Get("charon")
if r.OK {
h := r.Value.(*DriveHandle)
Println(h.Transport)
}
// Output: http://10.69.69.165:9101
}