-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix when resourceVersion updates multiple step in a short time, serve…
…r will not return response Signed-off-by: haorenfsa <[email protected]>
- Loading branch information
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package stream | ||
|
||
import "testing" | ||
|
||
func TestStreamStateUpdateNoReace(t *testing.T) { | ||
state := NewStreamState(false, map[string]string{ | ||
"resource": "1", | ||
}) | ||
// simulate server side update resource from 1->2 finished, sending response | ||
nextVersion2 := state.GetResourceVersions() | ||
nextVersion2["resource"] = "2" | ||
|
||
// simulate server side update resource from 2->3 finished, sending response | ||
nextVersion3 := state.GetResourceVersions() | ||
nextVersion3["resource"] = "3" | ||
|
||
// 1->2 response sent to client, update sate | ||
state.SetResourceVersions(nextVersion2) | ||
|
||
// should updated to 2, not 3, because 3 not sent yet | ||
result := state.GetResourceVersions() | ||
if result["resource"] != "2" { | ||
t.Errorf("expected version updated to 2, got %v", result["resource"]) | ||
} | ||
} |