examples/edgeindex: move example from main to example_test (#706)

This commit is contained in:
Ariel Mashraki
2020-08-28 18:10:20 +03:00
committed by GitHub
parent 48389c5e94
commit bcf262a66e
2 changed files with 9 additions and 2 deletions

View File

@@ -8,3 +8,9 @@ street name to be unique under each city.
```console
go generate ./...
```
### Run Example
```console
go test
```

View File

@@ -14,20 +14,21 @@ import (
_ "github.com/mattn/go-sqlite3"
)
func main() {
func Example_EdgeIndex() {
client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1")
if err != nil {
log.Fatalf("failed opening connection to sqlite: %v", err)
}
defer client.Close()
ctx := context.Background()
// run the auto migration tool.
// Run the auto migration tool.
if err := client.Schema.Create(ctx); err != nil {
log.Fatalf("failed creating schema resources: %v", err)
}
if err := Do(ctx, client); err != nil {
log.Fatal(err)
}
// Output:
}
func Do(ctx context.Context, client *ent.Client) error {