Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions types/function_list_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,41 @@ func Test_GetEmptyFunctions(t *testing.T) {
t.Errorf("Functions - want: %d items, got: %d", 0, len(functions))
}
}

func Test_GetFunctions_With_404Namespaces_Provider(t *testing.T) {

srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/system/namespaces" {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte("Not available"))
} else {
functions := []types.FunctionStatus{}
annotationMap := make(map[string]string)
annotationMap["topic"] = "topic1"

functions = append(functions, types.FunctionStatus{
Name: "echo",
Annotations: &annotationMap,
Namespace: "openfaas-fn",
})

bytesOut, _ := json.Marshal(functions)
w.Write(bytesOut)
}
}))

client := srv.Client()
builder := FunctionLookupBuilder{
Client: client,
GatewayURL: srv.URL,
TopicDelimiter: ",",
}

functions, err := builder.getFunctions("")
if err != nil {
t.Errorf("%s", err)
}
if len(functions) != 1 {
t.Errorf("Functions - want: %d items, got: %d", 1, len(functions))
}
}