virtualpaper icon indicating copy to clipboard operation
virtualpaper copied to clipboard

Use ordered map instead of normal maps

Open tryffel opened this issue 1 year ago • 2 comments

In Go a map's order is not explicit and varies a bit. This does not affect Virtualpaper's operation but makes some tests unreliable and they fail 20% of the time. Examples are here:

document_history_test.go:128: 
        	Error Trace:	/__w/virtualpaper/virtualpaper/integration_tests/document_history_test.go:128
        	Error:      	Not equal: 
        	            	expected: "{\"key_id\":14,\"value_id\":15}"
        	            	actual  : "{\"key_id\":14,\"value_id\":14}"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-{"key_id":14,"value_id":15}
        	            	+{"key_id":14,"value_id":14}
        	Test:       	TestDocumentHistory/TestChangeMetadata
    document_history_test.go:132: 
        	Error Trace:	/__w/virtualpaper/virtualpaper/integration_tests/document_history_test.go:132
        	Error:      	Not equal: 
        	            	expected: "{\"key_id\":14,\"value_id\":14}"
        	            	actual  : "{\"key_id\":14,\"value_id\":15}"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-{"key_id":14,"value_id":14}
        	            	+{"key_id":14,"value_id":15}
        	Test:       	TestDocumentHistory/TestChangeMetadata

=== FAIL: integration_tests TestDocumentHistory (0.25s)

Some library is going to be needed to tackle this.

tryffel avatar May 16 '23 14:05 tryffel

I would love to work on this issue can you assign me this ?

Gauravvpnd avatar May 17 '23 10:05 Gauravvpnd

Absolutely! Please provide a pull request and we can continue there.

tryffel avatar May 18 '23 13:05 tryffel

This is outdated. Sorting the keys before doing diff solved it.

tryffel avatar Apr 14 '24 14:04 tryffel