|
| 1 | +// +build integration |
| 2 | + |
| 3 | +package function_test |
| 4 | + |
| 5 | +import ( |
| 6 | + boson "github.com/boson-project/func" |
| 7 | + "github.com/boson-project/func/knative" |
| 8 | + "testing" |
| 9 | +) |
| 10 | + |
| 11 | +/* |
| 12 | + NOTE: Running integration tests locally requires a configured test cluster. |
| 13 | + Test failures may require manual removal of dangling resources. |
| 14 | +
|
| 15 | + ## Integration Cluster |
| 16 | +
|
| 17 | + These integration tests require a properly configured cluster, |
| 18 | + such as that which is setup and configured in CI (see .github/workflows). |
| 19 | + A local KinD cluster can be started via: |
| 20 | + ./hack/allocate.sh && ./hack/configure.sh |
| 21 | +
|
| 22 | + ## Integration Testing |
| 23 | +
|
| 24 | + These tests can be run via the make target: |
| 25 | + make integration |
| 26 | + or manually by specifying the tag |
| 27 | + go test -v -tags integration ./... |
| 28 | +
|
| 29 | + ## Teardown and Cleanup |
| 30 | +
|
| 31 | + Tests should clean up after themselves. In the event of failures, one may |
| 32 | + need to manually remove files: |
| 33 | + rm -rf ./testdata/example.com |
| 34 | + The test cluster is not automatically removed, as it can be reused. To remove: |
| 35 | + ./hack/delete.sh |
| 36 | +*/ |
| 37 | + |
| 38 | +const DefaultNamespace = "func" |
| 39 | + |
| 40 | +func TestList(t *testing.T) { |
| 41 | + verbose := true |
| 42 | + |
| 43 | + // Assemble |
| 44 | + lister, err := knative.NewLister(DefaultNamespace) |
| 45 | + if err != nil { |
| 46 | + t.Fatal(err) |
| 47 | + } |
| 48 | + client := boson.New( |
| 49 | + boson.WithLister(lister), |
| 50 | + boson.WithVerbose(verbose)) |
| 51 | + |
| 52 | + // Act |
| 53 | + names, err := client.List() |
| 54 | + if err != nil { |
| 55 | + t.Fatal(err) |
| 56 | + } |
| 57 | + |
| 58 | + // Assert |
| 59 | + if len(names) != 0 { |
| 60 | + t.Fatalf("Expected no Functions, got %v", names) |
| 61 | + } |
| 62 | +} |
0 commit comments