Fix patroni test with mock.
This commit is contained in:
		
							parent
							
								
									3e0a5d03a9
								
							
						
					
					
						commit
						510985ffd8
					
				| 
						 | 
				
			
			@ -144,7 +144,7 @@ type MemberData struct {
 | 
			
		|||
	State           string            `json:"state"`
 | 
			
		||||
	Role            string            `json:"role"`
 | 
			
		||||
	ServerVersion   int               `json:"server_version"`
 | 
			
		||||
	PendingRestart  string            `json:"pending_restart"`
 | 
			
		||||
	PendingRestart  bool              `json:"pending_restart"`
 | 
			
		||||
	ClusterUnlocked bool              `json:"cluster_unlocked"`
 | 
			
		||||
	Patroni         MemberDataPatroni `json:"patroni"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,13 +93,18 @@ func TestPatroniAPI(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	mockClient := mocks.NewMockHTTPClient(ctrl)
 | 
			
		||||
	mockClient.EXPECT().Get(gomock.Any()).Return(&response)
 | 
			
		||||
	mockClient.EXPECT().Get(gomock.Any()).Return(&response, nil)
 | 
			
		||||
 | 
			
		||||
	p := New(nil, mockClient)
 | 
			
		||||
 | 
			
		||||
	_, err := p.GetMemberData(nil)
 | 
			
		||||
	pod := v1.Pod{
 | 
			
		||||
		Status: v1.PodStatus{
 | 
			
		||||
			PodIP: "192.168.100.1",
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	_, err := p.GetMemberData(&pod)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Errorf("Could not read Patroni data")
 | 
			
		||||
		t.Errorf("Could not read Patroni data: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue