You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/app_test.go

54 lines
891 B

4 years ago
package kratos
import (
"testing"
"time"
"github.com/go-kratos/kratos/v2/transport/grpc"
"github.com/go-kratos/kratos/v2/transport/http"
"github.com/stretchr/testify/assert"
4 years ago
)
func TestApp(t *testing.T) {
hs := http.NewServer()
gs := grpc.NewServer()
app := New(
Name("kratos"),
Version("v1.0.0"),
Server(hs, gs),
)
time.AfterFunc(time.Second, func() {
app.Stop()
})
if err := app.Run(); err != nil {
t.Fatal(err)
}
}
func TestApp_ID(t *testing.T) {
v := "123"
o := New(ID(v))
assert.Equal(t, v, o.ID())
}
func TestApp_Name(t *testing.T) {
v := "123"
o := New(Name(v))
assert.Equal(t, v, o.Name())
}
func TestApp_Version(t *testing.T) {
v := "123"
o := New(Version(v))
assert.Equal(t, v, o.Version())
}
func TestApp_Metadata(t *testing.T) {
v := map[string]string{
"a": "1",
"b": "2",
}
o := New(Metadata(v))
assert.Equal(t, v, o.Metadata())
}