()
| 93 | } |
| 94 | |
| 95 | func (s *DatabaseSuite) Test_Apps() { |
| 96 | userBuilder := s.db.User(1) |
| 97 | userBuilder.App(1) |
| 98 | newAppActual := userBuilder.NewAppWithToken(2, "asdf") |
| 99 | newInternalAppActual := userBuilder.NewInternalAppWithToken(3, "qwer") |
| 100 | |
| 101 | s.db.User(2).InternalApp(5) |
| 102 | |
| 103 | newAppExpected := &model.Application{ID: 2, Token: "asdf", UserID: 1, SortKey: "a1"} |
| 104 | newInternalAppExpected := &model.Application{ID: 3, Token: "qwer", UserID: 1, Internal: true, SortKey: "a2"} |
| 105 | |
| 106 | assert.Equal(s.T(), newAppExpected, newAppActual) |
| 107 | assert.Equal(s.T(), newInternalAppExpected, newInternalAppActual) |
| 108 | |
| 109 | userOneExpected := []*model.Application{ |
| 110 | {ID: 1, Token: "app1", UserID: 1, SortKey: "a0"}, |
| 111 | {ID: 2, Token: "asdf", UserID: 1, SortKey: "a1"}, |
| 112 | {ID: 3, Token: "qwer", UserID: 1, Internal: true, SortKey: "a2"}, |
| 113 | } |
| 114 | if app, err := s.db.GetApplicationsByUser(1); assert.NoError(s.T(), err) { |
| 115 | assert.Equal(s.T(), userOneExpected, app) |
| 116 | } |
| 117 | userTwoExpected := []*model.Application{{ID: 5, Token: "app5", UserID: 2, Internal: true, SortKey: "a0"}} |
| 118 | if app, err := s.db.GetApplicationsByUser(2); assert.NoError(s.T(), err) { |
| 119 | assert.Equal(s.T(), userTwoExpected, app) |
| 120 | } |
| 121 | |
| 122 | newAppWithName := userBuilder.NewAppWithTokenAndName(7, "test-token", "app name") |
| 123 | newAppWithNameExpected := &model.Application{ID: 7, Token: "test-token", UserID: 1, Name: "app name", SortKey: "a3"} |
| 124 | assert.Equal(s.T(), newAppWithNameExpected, newAppWithName) |
| 125 | |
| 126 | newInternalAppWithName := userBuilder.NewInternalAppWithTokenAndName(8, "test-tokeni", "app name") |
| 127 | newInternalAppWithNameExpected := &model.Application{ID: 8, Token: "test-tokeni", UserID: 1, Name: "app name", Internal: true, SortKey: "a4"} |
| 128 | assert.Equal(s.T(), newInternalAppWithNameExpected, newInternalAppWithName) |
| 129 | |
| 130 | userBuilder.AppWithTokenAndName(9, "test-token-2", "app name") |
| 131 | userBuilder.InternalAppWithTokenAndName(10, "test-tokeni-2", "app name") |
| 132 | userBuilder.AppWithToken(11, "test-token-3") |
| 133 | userBuilder.InternalAppWithToken(12, "test-tokeni-3") |
| 134 | userBuilder.AppWithTokenAndDefaultPriority(13, "test-tokeni-4", 4) |
| 135 | |
| 136 | s.db.AssertAppExist(1) |
| 137 | s.db.AssertAppExist(2) |
| 138 | s.db.AssertAppExist(3) |
| 139 | s.db.AssertAppNotExist(4) |
| 140 | s.db.AssertAppExist(5) |
| 141 | s.db.AssertAppNotExist(6) |
| 142 | s.db.AssertAppExist(7) |
| 143 | s.db.AssertAppExist(8) |
| 144 | s.db.AssertAppExist(9) |
| 145 | s.db.AssertAppExist(10) |
| 146 | s.db.AssertAppExist(11) |
| 147 | s.db.AssertAppExist(12) |
| 148 | s.db.AssertAppExist(13) |
| 149 | |
| 150 | s.db.DeleteApplicationByID(2) |
| 151 | |
| 152 | s.db.AssertAppNotExist(2) |
nothing calls this directly
no test coverage detected