gofmt
parent
3d18984c70
commit
8c045ad08a
|
@ -247,13 +247,11 @@ func (h *VariableHandler) handlePostVariable(w http.ResponseWriter, r *http.Requ
|
|||
va := new(platform.Variable)
|
||||
va = req.variable
|
||||
|
||||
fmt.Println("1-->", va)
|
||||
err = h.VariableService.CreateVariable(ctx, va)
|
||||
if err != nil {
|
||||
EncodeError(ctx, err, w)
|
||||
return
|
||||
}
|
||||
fmt.Println("2-->",va)
|
||||
if err := encodeResponse(ctx, w, http.StatusCreated, newVariableResponse(req.variable, []*platform.Label{})); err != nil {
|
||||
logEncodingError(h.Logger, r, err)
|
||||
return
|
||||
|
|
|
@ -31,6 +31,7 @@ var bucketCmpOptions = cmp.Options{
|
|||
return out
|
||||
}),
|
||||
}
|
||||
|
||||
// BucketFields will include the IDGenerator, and buckets
|
||||
type BucketFields struct {
|
||||
IDGenerator platform.IDGenerator
|
||||
|
|
|
@ -56,22 +56,22 @@ func VariableService(
|
|||
name: "CreateVariable",
|
||||
fn: CreateVariable,
|
||||
},
|
||||
//{
|
||||
// name: "FindVariableByID",
|
||||
// fn: FindVariableByID,
|
||||
//},
|
||||
//{
|
||||
// name: "FindVariables",
|
||||
// fn: FindVariables,
|
||||
//},
|
||||
//{
|
||||
// name: "UpdateVariable",
|
||||
// fn: UpdateVariable,
|
||||
//},
|
||||
//{
|
||||
// name: "DeleteVariable",
|
||||
// fn: DeleteVariable,
|
||||
//},
|
||||
{
|
||||
name: "FindVariableByID",
|
||||
fn: FindVariableByID,
|
||||
},
|
||||
{
|
||||
name: "FindVariables",
|
||||
fn: FindVariables,
|
||||
},
|
||||
{
|
||||
name: "UpdateVariable",
|
||||
fn: UpdateVariable,
|
||||
},
|
||||
{
|
||||
name: "DeleteVariable",
|
||||
fn: DeleteVariable,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
@ -148,74 +148,74 @@ func CreateVariable(init func(VariableFields, *testing.T) (platform.VariableServ
|
|||
},
|
||||
},
|
||||
},
|
||||
//{
|
||||
// name: "creating a variable assigns the variable an id and adds it to the store",
|
||||
// fields: VariableFields{
|
||||
// IDGenerator: &mock.IDGenerator{
|
||||
// IDFn: func() platform.ID {
|
||||
// return MustIDBase16(idA)
|
||||
// },
|
||||
// },
|
||||
// TimeGenerator: fakeGenerator,
|
||||
// Variables: []*platform.Variable{
|
||||
// {
|
||||
// ID: MustIDBase16(idB),
|
||||
// OrganizationID: platform.ID(3),
|
||||
// Name: "existing-variable",
|
||||
// Selected: []string{"b"},
|
||||
// Arguments: &platform.VariableArguments{
|
||||
// Type: "constant",
|
||||
// Values: platform.VariableConstantValues{"b"},
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// args: args{
|
||||
// variable: &platform.Variable{
|
||||
// ID: MustIDBase16(idA),
|
||||
// OrganizationID: platform.ID(3),
|
||||
// Name: "my-variable",
|
||||
// Selected: []string{"a"},
|
||||
// Arguments: &platform.VariableArguments{
|
||||
// Type: "constant",
|
||||
// Values: platform.VariableConstantValues{"a"},
|
||||
// },
|
||||
// CRUDLog: platform.CRUDLog{
|
||||
// CreatedAt: fakeDate,
|
||||
// UpdatedAt: fakeDate,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// wants: wants{
|
||||
// err: nil,
|
||||
// variables: []*platform.Variable{
|
||||
// {
|
||||
// ID: MustIDBase16(idB),
|
||||
// OrganizationID: platform.ID(3),
|
||||
// Name: "existing-variable",
|
||||
// Selected: []string{"b"},
|
||||
// Arguments: &platform.VariableArguments{
|
||||
// Type: "constant",
|
||||
// Values: platform.VariableConstantValues{"b"},
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// ID: MustIDBase16(idA),
|
||||
// OrganizationID: platform.ID(3),
|
||||
// Name: "my-variable",
|
||||
// Selected: []string{"a"},
|
||||
// Arguments: &platform.VariableArguments{
|
||||
// Type: "constant",
|
||||
// Values: platform.VariableConstantValues{"a"},
|
||||
// },
|
||||
// CRUDLog: platform.CRUDLog{
|
||||
// CreatedAt: fakeDate,
|
||||
// UpdatedAt: fakeDate,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
//},
|
||||
{
|
||||
name: "creating a variable assigns the variable an id and adds it to the store",
|
||||
fields: VariableFields{
|
||||
IDGenerator: &mock.IDGenerator{
|
||||
IDFn: func() platform.ID {
|
||||
return MustIDBase16(idA)
|
||||
},
|
||||
},
|
||||
TimeGenerator: fakeGenerator,
|
||||
Variables: []*platform.Variable{
|
||||
{
|
||||
ID: MustIDBase16(idB),
|
||||
OrganizationID: platform.ID(3),
|
||||
Name: "existing-variable",
|
||||
Selected: []string{"b"},
|
||||
Arguments: &platform.VariableArguments{
|
||||
Type: "constant",
|
||||
Values: platform.VariableConstantValues{"b"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
variable: &platform.Variable{
|
||||
ID: MustIDBase16(idA),
|
||||
OrganizationID: platform.ID(3),
|
||||
Name: "my-variable",
|
||||
Selected: []string{"a"},
|
||||
Arguments: &platform.VariableArguments{
|
||||
Type: "constant",
|
||||
Values: platform.VariableConstantValues{"a"},
|
||||
},
|
||||
CRUDLog: platform.CRUDLog{
|
||||
CreatedAt: fakeDate,
|
||||
UpdatedAt: fakeDate,
|
||||
},
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
err: nil,
|
||||
variables: []*platform.Variable{
|
||||
{
|
||||
ID: MustIDBase16(idB),
|
||||
OrganizationID: platform.ID(3),
|
||||
Name: "existing-variable",
|
||||
Selected: []string{"b"},
|
||||
Arguments: &platform.VariableArguments{
|
||||
Type: "constant",
|
||||
Values: platform.VariableConstantValues{"b"},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(idA),
|
||||
OrganizationID: platform.ID(3),
|
||||
Name: "my-variable",
|
||||
Selected: []string{"a"},
|
||||
Arguments: &platform.VariableArguments{
|
||||
Type: "constant",
|
||||
Values: platform.VariableConstantValues{"a"},
|
||||
},
|
||||
CRUDLog: platform.CRUDLog{
|
||||
CreatedAt: fakeDate,
|
||||
UpdatedAt: fakeDate,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
Loading…
Reference in New Issue