Skip to content

Increase unit coverage#1685

Open
craigell wants to merge 3 commits into
dev-v2from
increase-unit-coverage
Open

Increase unit coverage#1685
craigell wants to merge 3 commits into
dev-v2from
increase-unit-coverage

Conversation

@craigell
Copy link
Copy Markdown
Contributor

@craigell craigell commented May 14, 2026

Proposed changes

Increased unit test coverage for agent v2.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@craigell craigell requested a review from a team as a code owner May 14, 2026 11:40
@github-actions github-actions Bot added chore Pull requests for routine tasks documentation Improvements or additions to documentation labels May 14, 2026
@craigell craigell added the v2.x Issues and Pull Requests related to the major version v2 label May 14, 2026
@craigell craigell self-assigned this May 14, 2026
Comment thread sdk/traverser_test.go Outdated
Comment thread src/core/config/types_test.go Outdated
Comment thread src/core/config/types_test.go Outdated
Comment thread src/core/logger/log_test.go
Comment thread sdk/grpc/meta_test.go
}

func TestNewMeta_EmptyArgs(t *testing.T) {
m := NewMeta("", "", "")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test and SetsAllFields and maybe the global meta tests could all be one tests

Comment thread sdk/grpc/meta_test.go
after := time.Now().Add(1 * time.Second)

require.NotNil(t, m.Timestamp)
ts := time.Unix(m.Timestamp.Seconds, int64(m.Timestamp.Nanos))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure I understand this test. For the timestamp we just do types.TimestampNow() so this feels like its just testing Go's timestamp.Now function

Comment thread sdk/grpc/meta_test.go
}

func TestNewMessageMeta_ConcurrentReads(t *testing.T) {
resetMetaForTest()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this test is needed, the go routines are just reading the values that are not being changed so wont find race conditions

assert.Equal(t, testBearer, ci.bearer)
}

func TestNewClientAuth_MultipleOptions(t *testing.T) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these tesNewClientAuth tests could be refactored to be done in the one test

assert.Equal(t, []string{testToken}, md.Get(TokenHeader))
}

func TestClientInterceptor_CustomLogger(t *testing.T) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this could be added to the NewClientAuth tests

"github.com/stretchr/testify/assert"
)

func TestClientInterceptor_ImplementsInterfaces(t *testing.T) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check can be done in the code its self I think with
var _ ClientInterceptor= (*clientInterceptor)(nil) in the client.go file

}
}

func TestGetTimeMetrics_Median(t *testing.T) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some of these tests can be joined into one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Pull requests for routine tasks documentation Improvements or additions to documentation v2.x Issues and Pull Requests related to the major version v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants