Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2020-02-18 16:58:48 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2020-02-18 16:59:44 +0300
commit5e9c2444f0271a73c83329e06355348c6dd89838 (patch)
treef9e1a55f64917ebe1aeedbcb41c9e5ed906c8ae6 /internal/source
parenta08ecdd06673d151dd6a9237b1056ca390e32424 (diff)
Simplify serverless serving and add a few tests
Diffstat (limited to 'internal/source')
-rw-r--r--internal/source/gitlab/api/lookup_path.go15
-rw-r--r--internal/source/gitlab/factory/serving_test.go44
2 files changed, 49 insertions, 10 deletions
diff --git a/internal/source/gitlab/api/lookup_path.go b/internal/source/gitlab/api/lookup_path.go
index de200e37..77b264ff 100644
--- a/internal/source/gitlab/api/lookup_path.go
+++ b/internal/source/gitlab/api/lookup_path.go
@@ -16,19 +16,14 @@ type Source struct {
Serverless Serverless `json:"serverless,omitempty"`
}
-// Serverless describeg serverless serving configuration
+// Serverless describes serverless serving configuration
type Serverless struct {
- Function function `json:"function,omitempty"`
- Cluster cluster `json:"cluster,omitempty"`
+ Service string `json:"service,omitempty"`
+ Cluster Cluster `json:"cluster,omitempty"`
}
-type function struct {
- Name string `json:"name,omitempty"`
- Domain string `json:"domain,omitempty"`
- Namespace string `json:"namespace,omitempty"`
-}
-
-type cluster struct {
+// Cluster describes serverless cluster configuration
+type Cluster struct {
Address string `json:"address,omitempty"`
Port string `json:"port,omitempty"`
Hostname string `json:"hostname,omitempty"`
diff --git a/internal/source/gitlab/factory/serving_test.go b/internal/source/gitlab/factory/serving_test.go
new file mode 100644
index 00000000..6d4a3787
--- /dev/null
+++ b/internal/source/gitlab/factory/serving_test.go
@@ -0,0 +1,44 @@
+package factory
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "gitlab.com/gitlab-org/gitlab-pages/internal/fixture"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/serving/disk"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/serving/serverless"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/source/gitlab/api"
+)
+
+func TestServing(t *testing.T) {
+ t.Run("when lookup path requires disk serving", func(t *testing.T) {
+ lookup := api.LookupPath{
+ Prefix: "/",
+ Source: api.Source{Type: "file"},
+ }
+
+ require.IsType(t, &disk.Disk{}, Serving(lookup))
+ })
+
+ t.Run("when lookup path requires serverless serving", func(t *testing.T) {
+ lookup := api.LookupPath{
+ Prefix: "/",
+ Source: api.Source{
+ Type: "serverless",
+ Serverless: api.Serverless{
+ Service: "my-func.knative.example.com",
+ Cluster: api.Cluster{
+ Address: "127.0.0.10",
+ Port: "443",
+ Hostname: "my-cluster.example.com",
+ CertificateCert: fixture.Certificate,
+ CertificateKey: fixture.Key,
+ },
+ },
+ },
+ }
+
+ require.IsType(t, &serverless.Serverless{}, Serving(lookup))
+ })
+}