notesmd-cli icon indicating copy to clipboard operation
notesmd-cli copied to clipboard

fix: replace flaky URI construction test by comparing parameters instead of strings

Open taylormonacelli opened this issue 1 year ago • 0 comments

replace flaky URI construction test by comparing parameters instead of strings

The TestUriConstruct test was failing intermittently because it compared the full URI string, which included query parameters in non-deterministic order due to Go map randomization.

Changed the test to parse query parameters and compare them by key-value pairs instead of doing string comparison. This validates the URI is semantically correct regardless of parameter order, which is the correct behavior since HTTP query parameters have no defined ordering.

Fixes the Two keys test case that was failing with:

expected: base-uri?key1=value1&key2=value2
actual:   base-uri?key2=value2&key1=value1

To reproduce the flaky behavior, run the test multiple times in the original version before this change.

for i in {1..10}; do go test ./pkg/obsidian -count=1 -run TestUriConstruct || break; done

Checklist:

  • [ ] I have written unit tests for my changes.
  • [ ] I have updated the documentation accordingly.
  • [x] All new and existing tests passed.

taylormonacelli avatar Oct 18 '25 04:10 taylormonacelli