New example files: entitlement, task, lock, log, drive, config, command, info. Every major source file now has a dedicated *_example_test.go with compilable, tested examples. 561 tests, 84.8% coverage. Co-Authored-By: Virgil <virgil@lethean.io>
36 lines
649 B
Go
36 lines
649 B
Go
package core_test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
. "dappco.re/go/core"
|
|
)
|
|
|
|
func ExampleDrive_New() {
|
|
c := New()
|
|
c.Drive().New(NewOptions(
|
|
Option{Key: "name", Value: "forge"},
|
|
Option{Key: "transport", Value: "https://forge.lthn.ai"},
|
|
))
|
|
|
|
fmt.Println(c.Drive().Has("forge"))
|
|
fmt.Println(c.Drive().Names())
|
|
// Output:
|
|
// true
|
|
// [forge]
|
|
}
|
|
|
|
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)
|
|
fmt.Println(h.Transport)
|
|
}
|
|
// Output: http://10.69.69.165:9101
|
|
}
|