revert: remove Go function (runtime compilation timeout)
This commit is contained in:
@@ -142,6 +142,77 @@ func TestUpdateFunctionCode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFunctionUsesSourceLiteralWhenDeploymentLiteralMissing(t *testing.T) {
|
||||
env := &unstructured.Unstructured{Object: map[string]any{
|
||||
"apiVersion": "fission.io/v1",
|
||||
"kind": "Environment",
|
||||
"metadata": map[string]any{"name": "go-acc", "namespace": "default"},
|
||||
}}
|
||||
|
||||
s := newTestServer(env)
|
||||
|
||||
pkg := &unstructured.Unstructured{Object: map[string]any{
|
||||
"apiVersion": "fission.io/v1",
|
||||
"kind": "Package",
|
||||
"metadata": map[string]any{
|
||||
"name": "fn-go-acc-pkg",
|
||||
"namespace": "default",
|
||||
},
|
||||
"spec": map[string]any{
|
||||
"source": map[string]any{
|
||||
"literal": base64.StdEncoding.EncodeToString([]byte("package main\n\nfunc Handler() {}\n")),
|
||||
},
|
||||
"deployment": map[string]any{
|
||||
"type": "url",
|
||||
"url": "http://storagesvc.fission/v1/archive?id=dummy",
|
||||
},
|
||||
},
|
||||
}}
|
||||
|
||||
fn := &unstructured.Unstructured{Object: map[string]any{
|
||||
"apiVersion": "fission.io/v1",
|
||||
"kind": "Function",
|
||||
"metadata": map[string]any{
|
||||
"name": "fn-go-acc",
|
||||
"namespace": "default",
|
||||
},
|
||||
"spec": map[string]any{
|
||||
"environment": map[string]any{"name": "go-acc", "namespace": "default"},
|
||||
"package": map[string]any{
|
||||
"functionName": "Handler",
|
||||
"packageref": map[string]any{
|
||||
"name": "fn-go-acc-pkg",
|
||||
"namespace": "default",
|
||||
},
|
||||
},
|
||||
},
|
||||
}}
|
||||
|
||||
if _, err := s.dyn.Resource(packageGVR).Namespace("default").Create(context.Background(), pkg, metav1.CreateOptions{}); err != nil {
|
||||
t.Fatalf("create package: %v", err)
|
||||
}
|
||||
if _, err := s.dyn.Resource(functionGVR).Namespace("default").Create(context.Background(), fn, metav1.CreateOptions{}); err != nil {
|
||||
t.Fatalf("create function: %v", err)
|
||||
}
|
||||
|
||||
getReq := httptest.NewRequest(http.MethodGet, "/api/functions/fn-go-acc", nil)
|
||||
getRec := httptest.NewRecorder()
|
||||
s.handleGetFunction(getRec, getReq, "fn-go-acc")
|
||||
if getRec.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d: %s", getRec.Code, getRec.Body.String())
|
||||
}
|
||||
|
||||
var out map[string]any
|
||||
if err := json.Unmarshal(getRec.Body.Bytes(), &out); err != nil {
|
||||
t.Fatalf("decode get response: %v", err)
|
||||
}
|
||||
|
||||
code, _ := out["code"].(string)
|
||||
if !strings.Contains(code, "func Handler") {
|
||||
t.Fatalf("expected source code from spec.source.literal, got %q", code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvokeFunctionWithJWTAuth(t *testing.T) {
|
||||
// Mock router: /auth/login returns JWT, /inv-fn returns hello
|
||||
var gotAuth string
|
||||
|
||||
Reference in New Issue
Block a user