Skip to content

Commit

Permalink
refactor(dqlite): rename Metadata.ImageId to Metadata.ImageID
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Fouillet <[email protected]>
  • Loading branch information
gfouillet committed Sep 23, 2024
1 parent 9422f01 commit 3737440
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions core/cloudimagemetadata/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ type Metadata struct {
// This will allow to sort metadata by importance.
Priority int

// ImageId contains image identifier.
ImageId string
// ImageID contains image identifier.
ImageID string

// CreationTime contains the time and date the image was created. This
// is populated when the Metadata is saved.
Expand Down
2 changes: 1 addition & 1 deletion domain/cloudimagemetadata/state/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ image_id
&dbMetadata.RootStorageSize,
&dbMetadata.Priority,
&dbMetadata.Arch,
&dbMetadata.ImageId,
&dbMetadata.ImageID,
); err != nil {
return errors.Trace(err)
}
Expand Down
4 changes: 2 additions & 2 deletions domain/cloudimagemetadata/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (s *State) SaveMetadata(ctx context.Context, metadata []cloudimagemetadata.
RootStorageType: m.RootStorageType,
RootStorageSize: m.RootStorageSize,
Priority: m.Priority,
ImageID: m.ImageId,
ImageID: m.ImageID,
})
}

Expand Down Expand Up @@ -317,7 +317,7 @@ WHERE %s;`, strings.Join(clauses, ` AND `))
Source: m.Source,
},
Priority: m.Priority,
ImageId: m.ImageID,
ImageID: m.ImageID,
CreationTime: m.CreatedAt,
}
}
Expand Down
36 changes: 18 additions & 18 deletions domain/cloudimagemetadata/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *stateSuite) TestSaveMetadata(c *gc.C) {
Source: "test",
}
expected := []cloudimagemetadata.Metadata{
{MetadataAttributes: attrs, Priority: 42, ImageId: "42"},
{MetadataAttributes: attrs, Priority: 42, ImageID: "42"},
}

// Act
Expand Down Expand Up @@ -107,7 +107,7 @@ func (s *stateSuite) TestSaveMetadataWithDateCreated(c *gc.C) {
Source: "test",
}
expected := []cloudimagemetadata.Metadata{
{MetadataAttributes: attrs, Priority: 42, ImageId: "42", CreationTime: testBeginTime},
{MetadataAttributes: attrs, Priority: 42, ImageID: "42", CreationTime: testBeginTime},
}

// Act
Expand Down Expand Up @@ -142,8 +142,8 @@ func (s *stateSuite) TestSaveMetadataSeveralMetadata(c *gc.C) {
RootStorageSize: ptr(uint64(1024)),
}
expected := []cloudimagemetadata.Metadata{
{MetadataAttributes: attrs1, ImageId: "1"},
{MetadataAttributes: attrs2, ImageId: "2"},
{MetadataAttributes: attrs1, ImageID: "1"},
{MetadataAttributes: attrs2, ImageID: "2"},
}

// Act
Expand Down Expand Up @@ -177,11 +177,11 @@ func (s *stateSuite) TestSaveMetadataUpdateMetadata(c *gc.C) {

// Act
err := s.state.SaveMetadata(context.Background(), []cloudimagemetadata.Metadata{
{MetadataAttributes: attrs1, ImageId: "1"},
{MetadataAttributes: attrs1, ImageID: "1"},
})
c.Assert(err, jc.ErrorIsNil)
err = s.state.SaveMetadata(context.Background(), []cloudimagemetadata.Metadata{
{MetadataAttributes: attrs2, ImageId: "2"},
{MetadataAttributes: attrs2, ImageID: "2"},
})
c.Assert(err, jc.ErrorIsNil)

Expand All @@ -193,7 +193,7 @@ func (s *stateSuite) TestSaveMetadataUpdateMetadata(c *gc.C) {
}
c.Assert(err, jc.ErrorIsNil)
c.Assert(obtained, jc.SameContents, []cloudimagemetadata.Metadata{
{MetadataAttributes: attrs1, ImageId: "2"}, // Imageid has been updated, but other attributes don't.
{MetadataAttributes: attrs1, ImageID: "2"}, // Imageid has been updated, but other attributes don't.
})
}

Expand All @@ -213,8 +213,8 @@ func (s *stateSuite) TestSaveMetadataWithSameAttributes(c *gc.C) {

// Act
err := s.state.SaveMetadata(context.Background(), []cloudimagemetadata.Metadata{
{MetadataAttributes: attrs1, ImageId: "1"},
{MetadataAttributes: attrs2, ImageId: "2"},
{MetadataAttributes: attrs1, ImageID: "1"},
{MetadataAttributes: attrs2, ImageID: "2"},
})

// Assert
Expand Down Expand Up @@ -242,9 +242,9 @@ func (s *stateSuite) TestSaveMetadataSeveralMetadataWithInvalidArchitecture(c *g
attrIncorrectArch.Arch = "unknownArch"

inserted := []cloudimagemetadata.Metadata{
{MetadataAttributes: attr1, ImageId: "1"},
{MetadataAttributes: attrIncorrectArch, ImageId: "2"},
{MetadataAttributes: attr2, ImageId: "3"},
{MetadataAttributes: attr1, ImageID: "1"},
{MetadataAttributes: attrIncorrectArch, ImageID: "2"},
{MetadataAttributes: attr2, ImageID: "3"},
}

// Act
Expand Down Expand Up @@ -284,7 +284,7 @@ VALUES
VirtType: "virtType-test",
RootStorageType: "rootStorageType-test",
Source: "custom",
}, Priority: 42, ImageId: "to-keep"},
}, Priority: 42, ImageID: "to-keep"},
})
}

Expand Down Expand Up @@ -414,7 +414,7 @@ VALUES
Source: "custom",
},
Priority: 42,
ImageId: "id",
ImageID: "id",
},
})
}
Expand Down Expand Up @@ -453,7 +453,7 @@ VALUES
Source: "custom",
},
Priority: 42,
ImageId: "id",
ImageID: "id",
},
{
MetadataAttributes: cloudimagemetadata.MetadataAttributes{
Expand All @@ -466,7 +466,7 @@ VALUES
Source: "custom",
},
Priority: 42,
ImageId: "id",
ImageID: "id",
},
})
}
Expand Down Expand Up @@ -513,7 +513,7 @@ VALUES
Source: "test",
}
expected := []cloudimagemetadata.Metadata{
{MetadataAttributes: attrs, Priority: 42, ImageId: "42"},
{MetadataAttributes: attrs, Priority: 42, ImageID: "42"},
}

// Act
Expand All @@ -537,5 +537,5 @@ VALUES
RootStorageType: "storage",
RootStorageSize: ptr(uint64(1024)),
Source: "custom",
}, Priority: 42, ImageId: "id"}))
}, Priority: 42, ImageID: "id"}))
}

0 comments on commit 3737440

Please sign in to comment.