Skip to main content

license_test.go

license_test.go - Overview

This file contains unit tests for the LicenseV3 struct and its associated NewLicenseV3 function, ensuring correct parsing and validation of license data from JSON payloads.

Detailed Documentation

TestNewLicenseV3

  • Purpose: Tests the NewLicenseV3 function with various JSON payloads to ensure it correctly parses and validates license data, handles errors, and sets default values when necessary.
  • Parameters:
    • t (*testing.T): Testing object for running test cases.
  • Returns: None

The test cases cover scenarios such as:

  • Missing or invalid license ID, key, status, and plan.
  • Correct parsing of a complete license payload.
  • Fallback to the basic plan if the license status is invalid.
  • Correctly parsing valid_from and valid_until timestamps and handling fallback states.

Code Examples

This section is not applicable as the code is self-explanatory and doesn't require extra examples.

Include in Getting Started: NO