Skip to content

Unit Test Configuration Values for Go #6

Description

@connerohnesorge

Add Unit Testing for V1 Nix Config - Go Protocol Buffer Plugins

Overview

Implement comprehensive unit testing using nix-unit to ensure our Go protocol buffer configuration maintains a consistent public interface and correctly maps to protoc plugin names.

Requirements

Core Testing Goals

  • Verify that public interface remains stable across changes
  • Ensure plugin names match their corresponding protoc-gen plugin names
  • Test all configurable values for Go protocol buffer plugins

Plugin Configuration Testing

Each protoc-gen plugin must be testable for:

  • Enablement: Each plugin should have an enable flag that can be toggled
  • Package Override: Each plugin should allow package redefinition for custom implementations

Implementation Details

Testing Framework

Use nix-unit with flake-parts integration:

perSystem = { ... }: {
  nix-unit.inputs = {
    # NOTE: nixpkgs-lib follows rule is currently required
    inherit (inputs) nixpkgs flake-parts nix-unit;
  };
  
  # Tests for Go protoc plugins
  nix-unit.tests = {
    # Test plugin enablement (default: disabled)
    "protoc-gen-go-enable" = {
      expr = self.mkBufrnixPackage.go.enable;
      expected = false;
    };
    
    # Test default package assignment
    "protoc-gen-go-package" = {
      expr = self.mkBufrnixPackage.go.package;
      expected = pkgs.protoc-gen-go;
    };
    
    # Additional plugin tests would follow the same pattern:
    # "protoc-gen-go-grpc-enable" = { ... };
    # "protoc-gen-go-grpc-package" = { ... };
  };
};

Test Coverage Requirements

Each test should validate:

  1. Plugin Name Mapping: Test values should correspond to actual protoc plugin names
  2. Default State: Plugins should be disabled by default (enable = false)
  3. Package Resolution: Default packages should point to correct nixpkgs derivations
  4. Interface Consistency: Public API should remain stable

Acceptance Criteria

  • All Go protoc-gen plugins have corresponding enable/package tests
  • Test names match protoc plugin naming conventions
  • Default configurations are properly tested
  • Tests pass in CI/CD pipeline
  • Documentation updated with testing approach

Additional Notes

This testing infrastructure will serve as a foundation for ensuring backward compatibility and preventing regressions in the public interface of our Nix Go configuration.

Activity

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

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions