mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-06-23 04:10:25 +00:00
d76074ae41
* add tests and mocks Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> update test Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> fix(agent/grpc): revert change Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> fix ci Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * refactor attestation and report tests Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> refactor tests Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> remove commented code Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> remove comment Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> remove comments * add test cases Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> export agent errors Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> remove comm Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * fix tests Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
49 lines
837 B
Go
49 lines
837 B
Go
// Copyright (c) Ultraviolet
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package sdk_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/ultravioletrs/cocos/agent"
|
|
agentgrpc "github.com/ultravioletrs/cocos/agent/api/grpc"
|
|
"github.com/ultravioletrs/cocos/agent/mocks"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/test/bufconn"
|
|
)
|
|
|
|
const bufSize = 1024 * 1024
|
|
|
|
var (
|
|
lis *bufconn.Listener
|
|
svc = &mocks.Service{}
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
lis = bufconn.Listen(bufSize)
|
|
s := grpc.NewServer()
|
|
|
|
agent.RegisterAgentServiceServer(s, agentgrpc.NewServer(svc))
|
|
|
|
go func() {
|
|
if err := s.Serve(lis); err != nil {
|
|
fmt.Println("Server exited with error:", err)
|
|
}
|
|
}()
|
|
|
|
code := m.Run()
|
|
|
|
s.Stop()
|
|
lis.Close()
|
|
os.Exit(code)
|
|
}
|
|
|
|
func bufDialer(context.Context, string) (net.Conn, error) {
|
|
return lis.Dial()
|
|
}
|