Skip to content

Commit

Permalink
Merge 2dad5bc into 27713b1
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherlogic committed Oct 25, 2019
2 parents 27713b1 + 2dad5bc commit fa3a0e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions recordadderapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ func (s *Server) AddRecord(ctx context.Context, req *pb.AddRecordRequest) (*pb.A
err = s.KSclient.Save(ctx, QUEUE, queue)
return &pb.AddRecordResponse{ExpectedAdditionDate: time.Now().Add(time.Hour * time.Duration((24 * len(queue.Requests)))).Unix()}, err
}

// Test test function
func (s *Server) Test(ctx context.Context, req *pb.AddRecordRequest) (*pb.AddRecordResponse, error) {
time.Sleep(time.Minute)
return nil, nil
}
8 changes: 7 additions & 1 deletion recordadderapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func InitTestServer() *Server {
s := Init()
s.SkipLog = true
s.GoServer.KSclient = *keystoreclient.GetTestClient(".test")
s.GoServer.KSclient.Save(context.Background(), QUEUE, &pb.Queue{})
return s
}

Expand All @@ -23,7 +24,7 @@ func TestAddRequest(t *testing.T) {

val, err := s.AddRecord(context.Background(), &pb.AddRecordRequest{})
if err != nil {
t.Errorf("Add Record failed: %v", err)
t.Fatalf("Add Record failed: %v", err)
}

if time.Now().After(time.Unix(val.ExpectedAdditionDate, 0)) {
Expand All @@ -40,3 +41,8 @@ func TestAddRequestFail(t *testing.T) {
t.Errorf("Add Record with failing read did not fail: %v", val)
}
}

func TestCallTest(t *testing.T) {
s := InitTestServer()
s.Test(context.Background(), &pb.AddRecordRequest{})
}
1 change: 1 addition & 0 deletions recordadderutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func InitTest() *Server {
s.rc = &testCollection{}
s.SkipLog = true
s.GoServer.KSclient = *keystoreclient.GetTestClient("./testing")
s.GoServer.KSclient.Save(context.Background(), QUEUE, &pb.Queue{})
return s
}

Expand Down

0 comments on commit fa3a0e1

Please sign in to comment.