Skip to content
Snippets Groups Projects
  • Christoph Glaubitz's avatar
    5d332fef
    Created generate scripts for basic functions and tests · 5d332fef
    Christoph Glaubitz authored
    Using Tenant as an example:
    
    The API types like Tenant, now go to
    `tenancy_tenants_types.go`. This file ends with two `go:generate`
    lines. One creates `tenancy_tenants.go` with the service and the functions
    like Get, List, Create... The second one creates basic tests in
    `tenant_tenants_basic_test.go`.
    
    As a result, `tenancy_tenants.go` and `tenancy_tenants_basic_test.go`
    should not be edited by hand. They will be overriden with the next
    `go generate`.
    
    Everything belonging to the type should go into
    `tenancy_tenants_types.go` (For example MarshalJSON.)
    All further tests, no matter if it targets
    the type (Tenant) or service (TenantsService), should go to
    `tenancy_tenants_test.go`.
    
    In this commit, both (`tenancy_tenant-groups_types.go` and
    `tenancy_tenants_type.go`) use `go:generate` to create functions and
    basic tests. But this is not a must, if it makes sense to implement
    endpoints by hand, this is totally fine.
    5d332fef
    History
    Created generate scripts for basic functions and tests
    Christoph Glaubitz authored
    Using Tenant as an example:
    
    The API types like Tenant, now go to
    `tenancy_tenants_types.go`. This file ends with two `go:generate`
    lines. One creates `tenancy_tenants.go` with the service and the functions
    like Get, List, Create... The second one creates basic tests in
    `tenant_tenants_basic_test.go`.
    
    As a result, `tenancy_tenants.go` and `tenancy_tenants_basic_test.go`
    should not be edited by hand. They will be overriden with the next
    `go generate`.
    
    Everything belonging to the type should go into
    `tenancy_tenants_types.go` (For example MarshalJSON.)
    All further tests, no matter if it targets
    the type (Tenant) or service (TenantsService), should go to
    `tenancy_tenants_test.go`.
    
    In this commit, both (`tenancy_tenant-groups_types.go` and
    `tenancy_tenants_type.go`) use `go:generate` to create functions and
    basic tests. But this is not a must, if it makes sense to implement
    endpoints by hand, this is totally fine.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.