MCPcopy Create free account
hub / github.com/cloudbase/garm / TestGetEntitiesUsingCredentials

Method TestGetEntitiesUsingCredentials

cache/cache_test.go:842–892  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

840}
841
842func (c *CacheTestSuite) TestGetEntitiesUsingCredentials() {
843 credentials := params.ForgeCredentials{
844 ID: 1,
845 Description: "test description",
846 Name: "test",
847 ForgeType: params.GithubEndpointType,
848 }
849
850 credentials2 := params.ForgeCredentials{
851 ID: 2,
852 Description: "test description2",
853 Name: "test",
854 ForgeType: params.GiteaEndpointType,
855 }
856
857 entity1 := params.ForgeEntity{
858 ID: "test-entity-1",
859 EntityType: params.ForgeEntityTypeOrganization,
860 Name: "test",
861 Owner: "test",
862 Credentials: credentials,
863 }
864
865 entity2 := params.ForgeEntity{
866 ID: "test-entity-2",
867 EntityType: params.ForgeEntityTypeOrganization,
868 Name: "test",
869 Owner: "test",
870 Credentials: credentials,
871 }
872 entity3 := params.ForgeEntity{
873 ID: "test-entity-3",
874 EntityType: params.ForgeEntityTypeOrganization,
875 Name: "test",
876 Owner: "test",
877 Credentials: credentials2,
878 }
879
880 SetEntity(entity1)
881 SetEntity(entity2)
882 SetEntity(entity3)
883
884 cachedEntities := GetEntitiesUsingCredentials(credentials)
885 c.Require().Len(cachedEntities, 2)
886 c.Require().Contains(cachedEntities, entity1)
887 c.Require().Contains(cachedEntities, entity2)
888
889 cachedEntities = GetEntitiesUsingCredentials(credentials2)
890 c.Require().Len(cachedEntities, 1)
891 c.Require().Contains(cachedEntities, entity3)
892}
893
894func (c *CacheTestSuite) TestGetallEntities() {
895 credentials := params.ForgeCredentials{

Callers

nothing calls this directly

Calls 3

SetEntityFunction · 0.85
LenMethod · 0.65

Tested by

no test coverage detected