| 55 | } |
| 56 | |
| 57 | func (m *FakeConnectionLogger) Contains(t testing.TB, expected database.UpsertConnectionLogParams) bool { |
| 58 | m.mu.Lock() |
| 59 | defer m.mu.Unlock() |
| 60 | for idx, cl := range m.upsertions { |
| 61 | if expected.ID != uuid.Nil && cl.ID != expected.ID { |
| 62 | t.Logf("connection log %d: expected ID %s, got %s", idx+1, expected.ID, cl.ID) |
| 63 | continue |
| 64 | } |
| 65 | if expected.OrganizationID != uuid.Nil && cl.OrganizationID != expected.OrganizationID { |
| 66 | t.Logf("connection log %d: expected OrganizationID %s, got %s", idx+1, expected.OrganizationID, cl.OrganizationID) |
| 67 | continue |
| 68 | } |
| 69 | if expected.WorkspaceOwnerID != uuid.Nil && cl.WorkspaceOwnerID != expected.WorkspaceOwnerID { |
| 70 | t.Logf("connection log %d: expected WorkspaceOwnerID %s, got %s", idx+1, expected.WorkspaceOwnerID, cl.WorkspaceOwnerID) |
| 71 | continue |
| 72 | } |
| 73 | if expected.WorkspaceID != uuid.Nil && cl.WorkspaceID != expected.WorkspaceID { |
| 74 | t.Logf("connection log %d: expected WorkspaceID %s, got %s", idx+1, expected.WorkspaceID, cl.WorkspaceID) |
| 75 | continue |
| 76 | } |
| 77 | if expected.WorkspaceName != "" && cl.WorkspaceName != expected.WorkspaceName { |
| 78 | t.Logf("connection log %d: expected WorkspaceName %s, got %s", idx+1, expected.WorkspaceName, cl.WorkspaceName) |
| 79 | continue |
| 80 | } |
| 81 | if expected.AgentName != "" && cl.AgentName != expected.AgentName { |
| 82 | t.Logf("connection log %d: expected AgentName %s, got %s", idx+1, expected.AgentName, cl.AgentName) |
| 83 | continue |
| 84 | } |
| 85 | if expected.Type != "" && cl.Type != expected.Type { |
| 86 | t.Logf("connection log %d: expected Type %s, got %s", idx+1, expected.Type, cl.Type) |
| 87 | continue |
| 88 | } |
| 89 | if expected.Code.Valid && cl.Code.Int32 != expected.Code.Int32 { |
| 90 | t.Logf("connection log %d: expected Code %d, got %d", idx+1, expected.Code.Int32, cl.Code.Int32) |
| 91 | continue |
| 92 | } |
| 93 | if expected.IP.Valid && cl.IP.IPNet.String() != expected.IP.IPNet.String() { |
| 94 | t.Logf("connection log %d: expected IP %s, got %s", idx+1, expected.IP.IPNet, cl.IP.IPNet) |
| 95 | continue |
| 96 | } |
| 97 | if expected.UserAgent.Valid && cl.UserAgent.String != expected.UserAgent.String { |
| 98 | t.Logf("connection log %d: expected UserAgent %s, got %s", idx+1, expected.UserAgent.String, cl.UserAgent.String) |
| 99 | continue |
| 100 | } |
| 101 | if expected.UserID.Valid && cl.UserID.UUID != expected.UserID.UUID { |
| 102 | t.Logf("connection log %d: expected UserID %s, got %s", idx+1, expected.UserID.UUID, cl.UserID.UUID) |
| 103 | continue |
| 104 | } |
| 105 | if expected.SlugOrPort.Valid && cl.SlugOrPort.String != expected.SlugOrPort.String { |
| 106 | t.Logf("connection log %d: expected SlugOrPort %s, got %s", idx+1, expected.SlugOrPort.String, cl.SlugOrPort.String) |
| 107 | continue |
| 108 | } |
| 109 | if expected.ConnectionID.Valid && cl.ConnectionID.UUID != expected.ConnectionID.UUID { |
| 110 | t.Logf("connection log %d: expected ConnectionID %s, got %s", idx+1, expected.ConnectionID.UUID, cl.ConnectionID.UUID) |
| 111 | continue |
| 112 | } |
| 113 | if expected.DisconnectReason.Valid && cl.DisconnectReason.String != expected.DisconnectReason.String { |
| 114 | t.Logf("connection log %d: expected DisconnectReason %s, got %s", idx+1, expected.DisconnectReason.String, cl.DisconnectReason.String) |