MCPcopy
hub / github.com/mudler/LocalAI / startTestServer

Function startTestServer

pkg/grpc/auth_test.go:27–42  ·  view source on GitHub ↗
(token string)

Source from the content-addressed store, hash-verified

25}
26
27func startTestServer(token string) (addr string, stop func()) {
28 old := os.Getenv(AuthTokenEnvVar)
29 os.Setenv(AuthTokenEnvVar, token)
30 DeferCleanup(func() { os.Setenv(AuthTokenEnvVar, old) })
31
32 lis, err := net.Listen("tcp", "127.0.0.1:0")
33 Expect(err).ToNot(HaveOccurred())
34
35 opts := serverOpts()
36 s := gogrpc.NewServer(opts...)
37 pb.RegisterBackendServer(s, &server{llm: &dummyModel{}})
38 go s.Serve(lis)
39 DeferCleanup(func() { s.GracefulStop() })
40
41 return lis.Addr().String(), func() {}
42}
43
44var _ = Describe("AuthInterceptor", func() {
45 // Not parallel: tests mutate the LOCALAI_GRPC_AUTH_TOKEN env var which is process-global.

Callers 1

auth_test.goFile · 0.85

Calls 3

serverOptsFunction · 0.85
AddrMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected