Skip to content

Add Tests for Prober Package #1138

@aryasoni98

Description

@aryasoni98

Problem

The prober package has 0% test coverage and needs comprehensive testing.

Current State

  • prober package: 0% test coverage
  • No tests for Interface implementation
  • No tests for Func wrapper
  • No tests for Go function
  • No tests for authorization handling
  • No tests for error handling

Acceptance Criteria

  • Interface implementation tested
  • Func wrapper tested
  • Go function tested with various scenarios
  • Authorization handling tested
  • Error handling tested
  • Test coverage >80%

Tasks

Core Interface Testing

  • Test Interface implementation

    func TestInterface(t *testing.T) {
        // Test that Interface can be implemented
        var _ prober.Interface = &mockProber{}
    }
  • Test Func wrapper

    func TestFunc(t *testing.T) {
        called := false
        fn := prober.Func(func(ctx context.Context) error {
            called = true
            return nil
        })
        
        err := fn.Probe(context.Background())
        assert.NoError(t, err)
        assert.True(t, called)
    }

Go Function Testing

  • Test Go function with valid authorization
  • Test Go function with invalid authorization
  • Test Go function with missing authorization
  • Test Go function with probe errors
  • Test Go function with different ports

Authorization Testing

  • Test valid authorization header
  • Test invalid authorization header
  • Test missing authorization header
  • Test authorization environment variable

Error Handling Testing

  • Test probe function returning errors
  • Test HTTP server errors
  • Test context cancellation
  • Test timeout scenarios

Test Files to Create

  • pkg/prober/prober_test.go

Success Metrics

  • Target: >80% test coverage
  • Current: 0%
  • Measurement: go test -coverprofile=coverage.out ./pkg/prober/...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions