()
| 763 | } |
| 764 | |
| 765 | func (c *CacheTestSuite) TestUpdateCredentialsInAffectedEntities() { |
| 766 | credentials := params.ForgeCredentials{ |
| 767 | ID: 1, |
| 768 | Description: "test description", |
| 769 | } |
| 770 | entity1 := params.ForgeEntity{ |
| 771 | ID: "test-entity-1", |
| 772 | EntityType: params.ForgeEntityTypeOrganization, |
| 773 | Name: "test", |
| 774 | Owner: "test", |
| 775 | Credentials: credentials, |
| 776 | } |
| 777 | |
| 778 | entity2 := params.ForgeEntity{ |
| 779 | ID: "test-entity-2", |
| 780 | EntityType: params.ForgeEntityTypeOrganization, |
| 781 | Name: "test", |
| 782 | Owner: "test", |
| 783 | Credentials: credentials, |
| 784 | } |
| 785 | |
| 786 | SetEntity(entity1) |
| 787 | SetEntity(entity2) |
| 788 | |
| 789 | cachedEntity1, ok := GetEntity(entity1.ID) |
| 790 | c.Require().True(ok) |
| 791 | c.Require().Equal(entity1.ID, cachedEntity1.ID) |
| 792 | cachedEntity2, ok := GetEntity(entity2.ID) |
| 793 | c.Require().True(ok) |
| 794 | c.Require().Equal(entity2.ID, cachedEntity2.ID) |
| 795 | |
| 796 | c.Require().Equal(credentials.ID, cachedEntity1.Credentials.ID) |
| 797 | c.Require().Equal(credentials.ID, cachedEntity2.Credentials.ID) |
| 798 | c.Require().Equal(credentials.Description, cachedEntity1.Credentials.Description) |
| 799 | c.Require().Equal(credentials.Description, cachedEntity2.Credentials.Description) |
| 800 | |
| 801 | credentials.Description = "new description" |
| 802 | SetGiteaCredentials(credentials) |
| 803 | |
| 804 | cachedEntity1, ok = GetEntity(entity1.ID) |
| 805 | c.Require().True(ok) |
| 806 | c.Require().Equal(entity1.ID, cachedEntity1.ID) |
| 807 | cachedEntity2, ok = GetEntity(entity2.ID) |
| 808 | c.Require().True(ok) |
| 809 | c.Require().Equal(entity2.ID, cachedEntity2.ID) |
| 810 | |
| 811 | c.Require().Equal(credentials.ID, cachedEntity1.Credentials.ID) |
| 812 | c.Require().Equal(credentials.ID, cachedEntity2.Credentials.ID) |
| 813 | c.Require().Equal(credentials.Description, cachedEntity1.Credentials.Description) |
| 814 | c.Require().Equal(credentials.Description, cachedEntity2.Credentials.Description) |
| 815 | } |
| 816 | |
| 817 | func (c *CacheTestSuite) TestSetGiteaEntity() { |
| 818 | credentials := params.ForgeCredentials{ |
nothing calls this directly
no test coverage detected