Enhance documentation for API client and vehicle structures; improve test function naming for clarity
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 24s

This commit is contained in:
2025-07-06 15:15:12 -04:00
parent d8cf2c3fd7
commit 3c927fd83b
7 changed files with 61 additions and 64 deletions

View File

@ -7,6 +7,7 @@ import (
"time"
)
// timestamp returns the current time in milliseconds since epoch as a string.
func TestTimestamp(t *testing.T) {
ts1 := timestamp()
time.Sleep(1 * time.Millisecond)
@ -22,6 +23,7 @@ func TestTimestamp(t *testing.T) {
}
}
// timestamp returns the current time in milliseconds since epoch as a string.
func TestTimestamp_Format(t *testing.T) {
ts := timestamp()
matched, err := regexp.MatchString(`^\d+$`, ts)
@ -33,6 +35,7 @@ func TestTimestamp_Format(t *testing.T) {
}
}
// urlToGen replaces "api_gen" in the URL with the specified generation.
func TestUrlToGen(t *testing.T) {
tests := []struct {
url, gen, want string
@ -51,6 +54,7 @@ func TestUrlToGen(t *testing.T) {
}
}
// vinCheck validates the VIN check digit and returns the corrected VIN.
func TestVinCheck_Valid(t *testing.T) {
// Example valid VIN: 1HGCM82633A004352 (check digit is '3')
vin := "1HGCM82633A004352"
@ -63,6 +67,7 @@ func TestVinCheck_Valid(t *testing.T) {
}
}
// TestVinCheck_InvalidCheckDigit tests a VIN with an incorrect check digit.
func TestVinCheck_InvalidCheckDigit(t *testing.T) {
vin := "1HGCM82633A004352"
// Change check digit (9th char) to '9'
@ -77,6 +82,7 @@ func TestVinCheck_InvalidCheckDigit(t *testing.T) {
}
}
// TestVinCheck_WrongLength tests a VIN that is not 17 characters long.
func TestVinCheck_WrongLength(t *testing.T) {
vin := "1234567890123456" // 16 chars
valid, corrected := vinCheck(vin)
@ -88,6 +94,7 @@ func TestVinCheck_WrongLength(t *testing.T) {
}
}
// transcodeDigits computes the sum of the VIN digits according to the VIN rules.
func TestTranscodeDigits(t *testing.T) {
// Use a known VIN and manually compute the sum
vin := "1HGCM82633A004352"
@ -99,6 +106,7 @@ func TestTranscodeDigits(t *testing.T) {
}
}
// TestVinCheck_XCheckDigit tests a VIN with 'X' as the check digit.
func TestVinCheck_XCheckDigit(t *testing.T) {
// VIN with check digit 'X'
vin := "1M8GDM9AXKP042788"
@ -111,6 +119,7 @@ func TestVinCheck_XCheckDigit(t *testing.T) {
}
}
// TestUrlToGen_NoApiGen tests the case where the URL does not contain "api_gen".
func TestUrlToGen_NoApiGen(t *testing.T) {
url := "https://host/endpoint"
gen := "g1"