Explorar el Código

Add failure scenarios to db.CreateOrder unit tests

max furman hace 5 años
padre
commit
bdace1e53f
Se han modificado 2 ficheros con 8 adiciones y 8 borrados
  1. 0 2
      acme/db/nosql/order.go
  2. 8 6
      acme/db/nosql/order_test.go

+ 0 - 2
acme/db/nosql/order.go

@@ -3,7 +3,6 @@ package nosql
 import (
 	"context"
 	"encoding/json"
-	"fmt"
 	"sync"
 	"time"
 
@@ -95,7 +94,6 @@ func (db *DB) CreateOrder(ctx context.Context, o *acme.Order) error {
 		NotAfter:         o.NotAfter,
 		AuthorizationIDs: o.AuthorizationIDs,
 	}
-	fmt.Printf("dbo = %+v\n", dbo)
 	if err := db.save(ctx, o.ID, dbo, nil, "order", orderTable); err != nil {
 		return err
 	}

+ 8 - 6
acme/db/nosql/order_test.go

@@ -385,6 +385,8 @@ func TestDB_UpdateOrder(t *testing.T) {
 
 func TestDB_CreateOrder(t *testing.T) {
 	now := clock.Now()
+	nbf := now.Add(5 * time.Minute)
+	naf := now.Add(15 * time.Minute)
 	type test struct {
 		db  nosql.DB
 		o   *acme.Order
@@ -399,8 +401,8 @@ func TestDB_CreateOrder(t *testing.T) {
 				CertificateID: "certID",
 				Status:        acme.StatusValid,
 				ExpiresAt:     now,
-				NotBefore:     now,
-				NotAfter:      now,
+				NotBefore:     nbf,
+				NotAfter:      naf,
 				Identifiers: []acme.Identifier{
 					{Type: "dns", Value: "test.ca.smallstep.com"},
 					{Type: "dns", Value: "example.foo.com"},
@@ -443,8 +445,8 @@ func TestDB_CreateOrder(t *testing.T) {
 				CertificateID: "certID",
 				Status:        acme.StatusValid,
 				ExpiresAt:     now,
-				NotBefore:     now,
-				NotAfter:      now,
+				NotBefore:     nbf,
+				NotAfter:      naf,
 				Identifiers: []acme.Identifier{
 					{Type: "dns", Value: "test.ca.smallstep.com"},
 					{Type: "dns", Value: "example.foo.com"},
@@ -496,8 +498,8 @@ func TestDB_CreateOrder(t *testing.T) {
 				ProvisionerID: "provID",
 				Status:        acme.StatusValid,
 				ExpiresAt:     now,
-				NotBefore:     now,
-				NotAfter:      now,
+				NotBefore:     nbf,
+				NotAfter:      naf,
 				Identifiers: []acme.Identifier{
 					{Type: "dns", Value: "test.ca.smallstep.com"},
 					{Type: "dns", Value: "example.foo.com"},