Skip to content

Commit

Permalink
test(proto): add and update tests for proto/varlogpb/metadata.go
Browse files Browse the repository at this point in the history
- Removed unused functions from metadata.go
- Added comprehensive unit tests for metadata.go and metadata_test.go
- Improved test coverage for various scenarios
  • Loading branch information
ijsong committed Dec 13, 2024
1 parent 1001a00 commit cd27630
Show file tree
Hide file tree
Showing 2 changed files with 2,077 additions and 50 deletions.
28 changes: 0 additions & 28 deletions proto/varlogpb/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,6 @@ func (m *MetadataDescriptor) MustHaveStorageNode(id types.StorageNodeID) (*Stora
return m.Must().HaveStorageNode(id)
}

func (m *MetadataDescriptor) NotHaveStorageNode(id types.StorageNodeID) error {
if m == nil {
return errors.New("MetadataDescriptor is nil")
}
if snd := m.GetStorageNode(id); snd == nil {
return nil
}
return errors.Wrap(verrors.ErrExist, "storage node")
}

func (m *MetadataDescriptor) MustNotHaveStorageNode(id types.StorageNodeID) error {
return m.Must().NotHaveStorageNode(id)
}

func (m *MetadataDescriptor) InsertLogStream(ls *LogStreamDescriptor) error {
if m == nil || ls == nil {
return nil
Expand Down Expand Up @@ -519,20 +505,6 @@ func (m *MetadataDescriptor) MustHaveTopic(id types.TopicID) (*TopicDescriptor,
return m.Must().HaveTopic(id)
}

func (m *MetadataDescriptor) NotHaveTopic(id types.TopicID) error {
if m == nil {
return errors.New("MetadataDescriptor is nil")
}
if tnd := m.GetTopic(id); tnd == nil {
return nil
}
return errors.Wrap(verrors.ErrExist, "storage node")
}

func (m *MetadataDescriptor) MustNotHaveTopic(id types.TopicID) error {
return m.Must().NotHaveTopic(id)
}

func (t *TopicDescriptor) searchLogStream(id types.LogStreamID) (int, bool) {
i := sort.Search(len(t.LogStreams), func(i int) bool {
return t.LogStreams[i] >= id
Expand Down
Loading

0 comments on commit cd27630

Please sign in to comment.