HW15 WIP
parent
1131e2644f
commit
e8e738ee78
|
@ -28,10 +28,10 @@ generate:
|
||||||
compose-build:
|
compose-build:
|
||||||
sudo -S docker-compose -f ./cicd/docker-compose.yml build
|
sudo -S docker-compose -f ./cicd/docker-compose.yml build
|
||||||
|
|
||||||
compose-up:
|
up:
|
||||||
sudo -S docker-compose -f ./cicd/docker-compose.yml up -d
|
sudo -S docker-compose -f ./cicd/docker-compose.yml up -d --build
|
||||||
|
|
||||||
compose-down:
|
down:
|
||||||
sudo -S docker-compose -f ./cicd/docker-compose.yml down
|
sudo -S docker-compose -f ./cicd/docker-compose.yml down
|
||||||
|
|
||||||
calendar-start:
|
calendar-start:
|
||||||
|
|
|
@ -3,7 +3,7 @@ RUN mkdir -p /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go get -d ./cmd/calendar/.
|
RUN go get -d ./cmd/calendar/.
|
||||||
RUN GOOS=linux GOARCH=amd64 go build -a -o calendar ./cmd/calendar/.
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o calendar ./cmd/calendar/.
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
ENV APP_GRPC_ADDRESS=0.0.0.0
|
ENV APP_GRPC_ADDRESS=0.0.0.0
|
||||||
|
@ -14,7 +14,7 @@ ENV APP_API_ADDRESS=0.0.0.0
|
||||||
ENV APP_API_PORT=50053
|
ENV APP_API_PORT=50053
|
||||||
ENV APP_LOGGER_FILE=/calendar.log
|
ENV APP_LOGGER_FILE=/calendar.log
|
||||||
ENV APP_LOGGER_LEVEL=INFO
|
ENV APP_LOGGER_LEVEL=INFO
|
||||||
ENV APP_STORAGE_INMEMORY=true
|
ENV APP_STORAGE_INMEMORY=false
|
||||||
ENV APP_STORAGE_SQLHOST=psql
|
ENV APP_STORAGE_SQLHOST=psql
|
||||||
ENV APP_STORAGE_SQLPORT=5432
|
ENV APP_STORAGE_SQLPORT=5432
|
||||||
ENV APP_STORAGE_SQLDBASE=calendar
|
ENV APP_STORAGE_SQLDBASE=calendar
|
||||||
|
@ -25,4 +25,4 @@ COPY --from=builder /app/calendar ./sbin
|
||||||
EXPOSE ${APP_GRPC_PORT}
|
EXPOSE ${APP_GRPC_PORT}
|
||||||
EXPOSE ${APP_HTTP_PORT}
|
EXPOSE ${APP_HTTP_PORT}
|
||||||
EXPOSE ${APP_API_PORT}
|
EXPOSE ${APP_API_PORT}
|
||||||
CMD ["calendar"]
|
ENTRYPOINT ["calendar"]
|
||||||
|
|
|
@ -1,5 +1,68 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
|
calendar:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: ./cicd/calendar/Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ../calendar.log:/calendar.log
|
||||||
|
ports:
|
||||||
|
- "8888:8888"
|
||||||
|
- "50051:50051"
|
||||||
|
- "50053:50053"
|
||||||
|
expose:
|
||||||
|
- 8888
|
||||||
|
- 50051
|
||||||
|
- 50053
|
||||||
|
depends_on:
|
||||||
|
- psql
|
||||||
|
- goose
|
||||||
|
|
||||||
|
scheduler:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: ./cicd/scheduler/Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ../calendar.log:/calendar.log
|
||||||
|
depends_on:
|
||||||
|
- rabbitmq
|
||||||
|
- calendar
|
||||||
|
restart: on-failure
|
||||||
|
|
||||||
|
sender:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: ./cicd/sender/Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ../calendar.log:/calendar.log
|
||||||
|
depends_on:
|
||||||
|
- rabbitmq
|
||||||
|
restart: on-failure
|
||||||
|
|
||||||
|
goose:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: ./cicd/goose/Dockerfile
|
||||||
|
environment:
|
||||||
|
GOOSE_DRIVER: "postgres"
|
||||||
|
GOOSE_DBSTRING: "host=psql port=5432 user=calendar password=12345678 dbname=calendar sslmode=disable"
|
||||||
|
depends_on:
|
||||||
|
- psql
|
||||||
|
restart: on-failure
|
||||||
|
|
||||||
|
psql:
|
||||||
|
image: postgres:11-alpine
|
||||||
|
hostname: "psql"
|
||||||
|
container_name: psql
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: calendar
|
||||||
|
POSTGRES_PASSWORD: 12345678
|
||||||
|
POSTGRES_DB: calendar
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
expose:
|
||||||
|
- 5432
|
||||||
|
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
image: rabbitmq:3-management-alpine
|
image: rabbitmq:3-management-alpine
|
||||||
hostname: "rabbitmq"
|
hostname: "rabbitmq"
|
||||||
|
@ -12,28 +75,6 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "5672:5672"
|
- "5672:5672"
|
||||||
- "15672:15672"
|
- "15672:15672"
|
||||||
#calendar:
|
expose:
|
||||||
# build:
|
- 15672
|
||||||
# context: ..
|
- 5672
|
||||||
# dockerfile: ./cicd/calendar/Dockerfile
|
|
||||||
# ports:
|
|
||||||
# - "8888:8888"
|
|
||||||
# volumes:
|
|
||||||
# - ../calendar.log:/calendar.log
|
|
||||||
#scheduler:
|
|
||||||
# build:
|
|
||||||
# context: ..
|
|
||||||
# dockerfile: ./cicd/scheduler/Dockerfile
|
|
||||||
# volumes:
|
|
||||||
# - ../calendar.log:/calendar.log
|
|
||||||
# depends_on:
|
|
||||||
# - rabbitmq
|
|
||||||
# - calendar
|
|
||||||
#sender:
|
|
||||||
# build:
|
|
||||||
# context: ..
|
|
||||||
# dockerfile: ./cicd/sender/Dockerfile
|
|
||||||
# volumes:
|
|
||||||
# - ../calendar.log:/calendar.log
|
|
||||||
# depends_on:
|
|
||||||
# - rabbitmq
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
FROM golang:1.14
|
||||||
|
WORKDIR /
|
||||||
|
RUN go get -u github.com/pressly/goose/cmd/goose
|
||||||
|
COPY . .
|
||||||
|
ENTRYPOINT ["/go/bin/goose", "-dir", "migrations", "up"]
|
|
@ -3,7 +3,7 @@ RUN mkdir -p /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go get -d ./cmd/scheduler/.
|
RUN go get -d ./cmd/scheduler/.
|
||||||
RUN GOOS=linux GOARCH=amd64 go build -a -o scheduler ./cmd/scheduler/.
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o scheduler ./cmd/scheduler/.
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
ENV APP_RABBITMQ_ADDRESS=rabbitmq
|
ENV APP_RABBITMQ_ADDRESS=rabbitmq
|
||||||
|
@ -19,4 +19,4 @@ ENV APP_LOGGER_FILE=/calendar.log
|
||||||
ENV APP_LOGGER_LEVEL=INFO
|
ENV APP_LOGGER_LEVEL=INFO
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
COPY --from=builder /app/scheduler ./sbin
|
COPY --from=builder /app/scheduler ./sbin
|
||||||
CMD ["scheduler"]
|
ENTRYPOINT ["scheduler"]
|
||||||
|
|
|
@ -3,7 +3,7 @@ RUN mkdir -p /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go get -d ./cmd/sender/.
|
RUN go get -d ./cmd/sender/.
|
||||||
RUN GOOS=linux GOARCH=amd64 go build -a -o sender ./cmd/sender/.
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o sender ./cmd/sender/.
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
ENV APP_RABBITMQ_ADDRESS=rabbitmq
|
ENV APP_RABBITMQ_ADDRESS=rabbitmq
|
||||||
|
@ -17,4 +17,4 @@ ENV APP_LOGGER_FILE=/calendar.log
|
||||||
ENV APP_LOGGER_LEVEL=INFO
|
ENV APP_LOGGER_LEVEL=INFO
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
COPY --from=builder /app/sender ./sbin
|
COPY --from=builder /app/sender ./sbin
|
||||||
CMD ["sender"]
|
ENTRYPOINT ["sender"]
|
||||||
|
|
|
@ -9,10 +9,10 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/pkg/api/public"
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/pkg/api/public"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = func() bool {
|
var _ = func() bool {
|
||||||
|
@ -39,12 +39,13 @@ var testEvent02 = public.CreateReq{
|
||||||
NotifyTime: dur2pbduration(5 * time.Minute),
|
NotifyTime: dur2pbduration(5 * time.Minute),
|
||||||
UserID: 2222,
|
UserID: 2222,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
main()
|
main()
|
||||||
}(ctx)
|
}(ctx)
|
||||||
time.Sleep(1*time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
c := m.Run()
|
c := m.Run()
|
||||||
|
|
||||||
|
@ -116,29 +117,29 @@ func TestPublicGRPCEndpoint(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.GreaterOrEqual(t, len(list.Events), 2)
|
require.GreaterOrEqual(t, len(list.Events), 2)
|
||||||
var e1, e2 bool
|
var e1, e2 bool
|
||||||
for _,v := range list.Events {
|
for _, v := range list.Events {
|
||||||
if v.ID==resp1.ID {
|
if v.ID == resp1.ID {
|
||||||
e1=true
|
e1 = true
|
||||||
}
|
}
|
||||||
if v.ID==resp2.ID {
|
if v.ID == resp2.ID {
|
||||||
e2=true
|
e2 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require.True(t, e1)
|
require.True(t, e1)
|
||||||
require.True(t, e2)
|
require.True(t, e2)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("test public GRPC.Create and GRPC.GetByDate", func(t *testing.T){
|
t.Run("test public GRPC.Create and GRPC.GetByDate", func(t *testing.T) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
list, err := publicAPI.GetByDate(ctx,&public.GetByDateReq{Date: testEvent01.Date, Range: public.QueryRange_DAY})
|
list, err := publicAPI.GetByDate(ctx, &public.GetByDateReq{Date: testEvent01.Date, Range: public.QueryRange_DAY})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.GreaterOrEqual(t, len(list.Events), 2)
|
require.GreaterOrEqual(t, len(list.Events), 2)
|
||||||
var e1 bool
|
var e1 bool
|
||||||
for _,v := range list.Events {
|
for _, v := range list.Events {
|
||||||
if v.ID==resp1.ID {
|
if v.ID == resp1.ID {
|
||||||
e1=true
|
e1 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require.True(t, e1)
|
require.True(t, e1)
|
||||||
|
@ -211,29 +212,29 @@ func TestPublicAPIEndpoint(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.GreaterOrEqual(t, len(list.Events), 2)
|
require.GreaterOrEqual(t, len(list.Events), 2)
|
||||||
var e1, e2 bool
|
var e1, e2 bool
|
||||||
for _,v := range list.Events {
|
for _, v := range list.Events {
|
||||||
if v.ID==resp1.ID {
|
if v.ID == resp1.ID {
|
||||||
e1=true
|
e1 = true
|
||||||
}
|
}
|
||||||
if v.ID==resp2.ID {
|
if v.ID == resp2.ID {
|
||||||
e2=true
|
e2 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require.True(t, e1)
|
require.True(t, e1)
|
||||||
require.True(t, e2)
|
require.True(t, e2)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("test public GRPC.Create and GRPC.GetByDate", func(t *testing.T){
|
t.Run("test public GRPC.Create and GRPC.GetByDate", func(t *testing.T) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
list, err := publicAPI.GetByDate(ctx,&public.GetByDateReq{Date: testEvent01.Date, Range: public.QueryRange_DAY})
|
list, err := publicAPI.GetByDate(ctx, &public.GetByDateReq{Date: testEvent01.Date, Range: public.QueryRange_DAY})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.GreaterOrEqual(t, len(list.Events), 2)
|
require.GreaterOrEqual(t, len(list.Events), 2)
|
||||||
var e1 bool
|
var e1 bool
|
||||||
for _,v := range list.Events {
|
for _, v := range list.Events {
|
||||||
if v.ID==resp1.ID {
|
if v.ID == resp1.ID {
|
||||||
e1=true
|
e1 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require.True(t, e1)
|
require.True(t, e1)
|
||||||
|
@ -242,7 +243,6 @@ func TestPublicAPIEndpoint(t *testing.T) {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func time2pbtimestamp(t time.Time) *timestamp.Timestamp {
|
func time2pbtimestamp(t time.Time) *timestamp.Timestamp {
|
||||||
r, err := ptypes.TimestampProto(t)
|
r, err := ptypes.TimestampProto(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -2,14 +2,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/sheduler"
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/sheduler"
|
||||||
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/pkg/config"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/pkg/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var configFile string
|
var configFile string
|
||||||
|
|
|
@ -2,14 +2,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/sender"
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/sender"
|
||||||
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/pkg/config"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/pkg/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var configFile string
|
var configFile string
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
-- +goose Up
|
-- +goose Up
|
||||||
-- +goose StatementBegin
|
-- +goose StatementBegin
|
||||||
CREATE TABLE events (
|
CREATE TABLE events (
|
||||||
id int(16) NOT NULL AUTO_INCREMENT,
|
id serial NOT NULL,
|
||||||
title varchar(255) NOT NULL,
|
title varchar(255) NOT NULL,
|
||||||
date datetime NOT NULL,
|
date timestamptz NOT NULL,
|
||||||
latency int(16) NOT NULL,
|
latency int8 NOT NULL,
|
||||||
note text,
|
note text NULL,
|
||||||
userID int(16),
|
userID int8 NOT NULL,
|
||||||
notifyTime int(16),
|
notifyTime timestamptz NULL,
|
||||||
notified bool
|
notified bool
|
||||||
PRIMARY KEY (`id`)
|
);
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;;
|
|
||||||
-- +goose StatementEnd
|
-- +goose StatementEnd
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
|
|
|
@ -3,8 +3,9 @@ package public
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"google.golang.org/grpc"
|
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewClient(ctx context.Context, addr, port string) (GrpcClient, error) {
|
func NewClient(ctx context.Context, addr, port string) (GrpcClient, error) {
|
||||||
|
|
|
@ -35,11 +35,11 @@ var testEvent02 = public.CreateReq{
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := TestPublicAPIEndpoint(); err != nil {
|
if err := TestPublicAPIEndpoint(); err != nil {
|
||||||
log.Fatalf("TestPublicAPIEndpoint FAIL: %w",err)
|
log.Fatalf("TestPublicAPIEndpoint FAIL: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := TestPublicGRPCEndpoint(); err != nil {
|
if err := TestPublicGRPCEndpoint(); err != nil {
|
||||||
log.Fatalf("TestPublicGRPCEndpoint FAIL: %w",err)
|
log.Fatalf("TestPublicGRPCEndpoint FAIL: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,6 @@ func TestPublicGRPCEndpoint() error {
|
||||||
require.Equal(t, testEvent01.Date.Seconds, resp2.Events[0].Date.Seconds)
|
require.Equal(t, testEvent01.Date.Seconds, resp2.Events[0].Date.Seconds)
|
||||||
require.Equal(t, testEvent01.Note, resp2.Events[0].Note)
|
require.Equal(t, testEvent01.Note, resp2.Events[0].Note)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("test public GRPC.Create, GRPC.Update and GRPC.GetById", func(t *testing.T) {
|
t.Run("test public GRPC.Create, GRPC.Update and GRPC.GetById", func(t *testing.T) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
||||||
|
@ -85,7 +84,6 @@ func TestPublicGRPCEndpoint() error {
|
||||||
require.Equal(t, testEvent02.Date.Seconds, resp2.Events[0].Date.Seconds)
|
require.Equal(t, testEvent02.Date.Seconds, resp2.Events[0].Date.Seconds)
|
||||||
require.Equal(t, testEvent02.Note, resp2.Events[0].Note)
|
require.Equal(t, testEvent02.Note, resp2.Events[0].Note)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("test public GRPC.Create, GRPC.Delete and GRPC.GetById", func(t *testing.T) {
|
t.Run("test public GRPC.Create, GRPC.Delete and GRPC.GetById", func(t *testing.T) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
||||||
|
@ -97,7 +95,6 @@ func TestPublicGRPCEndpoint() error {
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Nil(t, resp2)
|
require.Nil(t, resp2)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("test public GRPC.Create and GRPC.List", func(t *testing.T) {
|
t.Run("test public GRPC.Create and GRPC.List", func(t *testing.T) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
||||||
|
@ -110,34 +107,32 @@ func TestPublicGRPCEndpoint() error {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.GreaterOrEqual(t, len(list.Events), 2)
|
require.GreaterOrEqual(t, len(list.Events), 2)
|
||||||
var e1, e2 bool
|
var e1, e2 bool
|
||||||
for _,v := range list.Events {
|
for _, v := range list.Events {
|
||||||
if v.ID==resp1.ID {
|
if v.ID == resp1.ID {
|
||||||
e1=true
|
e1 = true
|
||||||
}
|
}
|
||||||
if v.ID==resp2.ID {
|
if v.ID == resp2.ID {
|
||||||
e2=true
|
e2 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require.True(t, e1)
|
require.True(t, e1)
|
||||||
require.True(t, e2)
|
require.True(t, e2)
|
||||||
})
|
})
|
||||||
|
t.Run("test public GRPC.Create and GRPC.GetByDate", func(t *testing.T) {
|
||||||
t.Run("test public GRPC.Create and GRPC.GetByDate", func(t *testing.T){
|
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
list, err := publicAPI.GetByDate(ctx,&public.GetByDateReq{Date: testEvent01.Date, Range: public.QueryRange_DAY})
|
list, err := publicAPI.GetByDate(ctx, &public.GetByDateReq{Date: testEvent01.Date, Range: public.QueryRange_DAY})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.GreaterOrEqual(t, len(list.Events), 2)
|
require.GreaterOrEqual(t, len(list.Events), 2)
|
||||||
var e1 bool
|
var e1 bool
|
||||||
for _,v := range list.Events {
|
for _, v := range list.Events {
|
||||||
if v.ID==resp1.ID {
|
if v.ID == resp1.ID {
|
||||||
e1=true
|
e1 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require.True(t, e1)
|
require.True(t, e1)
|
||||||
})
|
})
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,29 +200,29 @@ func TestPublicAPIEndpoint() error {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.GreaterOrEqual(t, len(list.Events), 2)
|
require.GreaterOrEqual(t, len(list.Events), 2)
|
||||||
var e1, e2 bool
|
var e1, e2 bool
|
||||||
for _,v := range list.Events {
|
for _, v := range list.Events {
|
||||||
if v.ID==resp1.ID {
|
if v.ID == resp1.ID {
|
||||||
e1=true
|
e1 = true
|
||||||
}
|
}
|
||||||
if v.ID==resp2.ID {
|
if v.ID == resp2.ID {
|
||||||
e2=true
|
e2 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require.True(t, e1)
|
require.True(t, e1)
|
||||||
require.True(t, e2)
|
require.True(t, e2)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("test public GRPC.Create and GRPC.GetByDate", func(t *testing.T){
|
t.Run("test public GRPC.Create and GRPC.GetByDate", func(t *testing.T) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
resp1, err := publicAPI.Create(ctx, &testEvent01)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
list, err := publicAPI.GetByDate(ctx,&public.GetByDateReq{Date: testEvent01.Date, Range: public.QueryRange_DAY})
|
list, err := publicAPI.GetByDate(ctx, &public.GetByDateReq{Date: testEvent01.Date, Range: public.QueryRange_DAY})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.GreaterOrEqual(t, len(list.Events), 2)
|
require.GreaterOrEqual(t, len(list.Events), 2)
|
||||||
var e1 bool
|
var e1 bool
|
||||||
for _,v := range list.Events {
|
for _, v := range list.Events {
|
||||||
if v.ID==resp1.ID {
|
if v.ID == resp1.ID {
|
||||||
e1=true
|
e1 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require.True(t, e1)
|
require.True(t, e1)
|
||||||
|
@ -236,7 +231,6 @@ func TestPublicAPIEndpoint() error {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func time2pbtimestamp(t time.Time) *timestamp.Timestamp {
|
func time2pbtimestamp(t time.Time) *timestamp.Timestamp {
|
||||||
r, err := ptypes.TimestampProto(t)
|
r, err := ptypes.TimestampProto(t)
|
||||||
if err != nil {
|
if err != nil {
|
Loading…
Reference in New Issue