mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-09 16:36:47 +00:00
This patch completes part of the work in #20 by porting the code for faas-containerd in-tree. When tested, I was able to deploy and then remove figlet from the store on `x86_64`. In a follow-up PR, duplication will be removed where possible and consolidated with updated documentation. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
40 lines
998 B
Go
40 lines
998 B
Go
package handlers
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/openfaas/faas-provider/types"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func Test_InfoHandler(t *testing.T) {
|
|
sha := "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
|
|
version := "0.0.1"
|
|
handler := MakeInfoHandler(version, sha)
|
|
w := httptest.NewRecorder()
|
|
r := httptest.NewRequest("GET", "/", nil)
|
|
handler(w, r)
|
|
|
|
resp := types.InfoResponse{}
|
|
err := json.Unmarshal(w.Body.Bytes(), &resp)
|
|
if err != nil {
|
|
t.Fatalf("unexpected error unmarshalling the response")
|
|
}
|
|
|
|
if resp.Provider != ProviderName {
|
|
t.Fatalf("expected provider %q, got %q", ProviderName, resp.Provider)
|
|
}
|
|
|
|
if resp.Orchestration != OrchestrationIdentifier {
|
|
t.Fatalf("expected orchestration %q, got %q", OrchestrationIdentifier, resp.Orchestration)
|
|
}
|
|
|
|
if resp.Version.SHA != sha {
|
|
t.Fatalf("expected orchestration %q, got %q", sha, resp.Version.SHA)
|
|
}
|
|
|
|
if resp.Version.Release != version {
|
|
t.Fatalf("expected release %q, got %q", version, resp.Version.Release)
|
|
}
|
|
}
|