Skip to content

Commit

Permalink
Rename UserStore (#406)
Browse files Browse the repository at this point in the history
* rename UserStore, add some tests and rename linter method

* fix failed rename operation on squeaks behalf
  • Loading branch information
rsommerfeld authored Jun 26, 2021
1 parent 8ab9159 commit 9557bb5
Show file tree
Hide file tree
Showing 29 changed files with 87 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ initialize
chats: TCCChats newWithDefaultSorting;
loggedInUserID: 0;
pendingRequests: Dictionary new;
users: (TCCUsers newWith: self);
users: (TCCUserStore newWith: self);
imageStore: (TCCImageStore newWith: self);
callbackCounter: 0.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"handlePendingEvent:" : "5/30/2021 12:11:04",
"imageStore" : "pk 6/19/2021 17:15",
"imageStore:" : "TR 6/22/2021 09:33",
"initialize" : "pk 6/19/2021 17:21",
"initialize" : "RS 6/23/2021 15:29",
"initializeHandlers" : "js 8/1/2020 18:09",
"isClientAlive" : "js 5/28/2020 17:18",
"loggedInUserID" : "rs 7/5/2020 14:48",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ requestUserFor: aUserId with: aPromise
registerCallback:
[:userEvent | aPromise resolveWith: (TCCUser newFrom: userEvent)].

self core requestUser: aUserId with: callbackID
self core requestUser: aUserId with: callbackID.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"core" : "RK 5/19/2021 10:34",
"core:" : "TR 6/15/2021 16:52",
"getUserFor:" : "pk 6/19/2021 17:48",
"requestUserFor:with:" : "pk 6/19/2021 17:48" } }
"requestUserFor:with:" : "RS 6/23/2021 15:41" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"commentStamp" : "RK 5/19/2021 09:58",
"instvars" : [
"core" ],
"name" : "TCCUsers",
"name" : "TCCUserStore",
"pools" : [
],
"super" : "Dictionary",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
testing
testCanRequestUser

| callbackID user |

user := nil.

callbackID := self sharedCore
registerCallback:
[:userEvent | user := TCCUser newFrom: userEvent].

self sharedCore requestUser: self sharedCore loggedInUserID with: callbackID.
1 second wait.

self assert: user notNil.
self assert: self sharedCore loggedInUserID equals: user id.
self assert: user firstName isString.
self assert: user lastName isString.
self assert: user username isString.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"class" : {
},
"instance" : {
"testCanRequestUser" : "RS 6/23/2021 15:49",
"testExtraAPIAttribute" : "RS 6/6/2021 10:50",
"testMessageSending" : "RS 6/6/2021 10:54",
"testPositionIsUpdatedAfterInitialChatLoading" : "RS 6/13/2021 17:02" } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
testing
partialGroupMembersTestFor: aChat

self core users: TCTMMocks mockUserPromises.
self core users: TCTMMocks mockUserStore.
aChat core: self core.
aChat loadInfo.
1 seconds wait.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
},
"instance" : {
"newMessageReceived:" : "pk 5/17/2021 19:20",
"partialGroupMembersTestFor:" : "TR 6/13/2021 15:19",
"partialGroupMembersTestFor:" : "RS 6/23/2021 16:00",
"receivedMessage" : "TR 6/2/2021 15:46",
"receivedMessage:" : "TR 6/2/2021 15:47",
"testAuthConstants" : "js 8/2/2020 22:54",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
testing
testCachesRequests

| path1 path2 |
self mockTeleClient onRequestType: 'downloadFile' respond: TCTMMocks mockImageResponseJson.

[self core imageStore getFormFor: TCTMMocks mockImageId.] fork.
1 seconds wait.
path1 := (self core imageStore at: TCTMMocks mockImageId) value.

[self core imageStore getFormFor: TCTMMocks mockImageId.] fork.
1 seconds wait.
path2 := (self core imageStore at: TCTMMocks mockImageId) value.

self assert: path1 equals: path2.
self assert: 1 equals: self core imageStore size.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
},
"instance" : {
"setUp" : "pk 6/19/2021 17:37",
"testCachesRequests" : "RS 6/23/2021 15:51",
"testCanGetImageForm" : "pk 6/19/2021 17:02",
"testCanGetImagePath" : "pk 6/19/2021 17:24",
"testDidCreateFile" : "pk 6/19/2021 17:35" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
testing
testCachesRequests

| user1 user2 |
user1 := nil.
user2 := nil.

self mockTeleClient onRequestType: 'getUser' respond: TCTMMocks mockUserJson1.

[user1 := self core users getUserFor: TCTMMocks mockUser1 id.] fork.
1 seconds wait.

self assert: user1 notNil.
[user2 := self core users getUserFor: TCTMMocks mockUser1 id.] fork.
1 seconds wait.

self assert: user1 == user2.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
testing
testGetUserFor

| user |
user := nil.

self mockTeleClient onRequestType: 'getUser' respond: TCTMMocks mockUserJson1.

[user := self core users getUserFor: TCTMMocks mockUser1 id.] fork.
1 seconds wait.

self assert: TCTMMocks mockUser1 equals: user.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"class" : {
},
"instance" : {
"testCachesRequests" : "RS 6/23/2021 15:35",
"testGetUserFor" : "RS 6/23/2021 15:32" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"commentStamp" : "RK 5/19/2021 10:18",
"instvars" : [
],
"name" : "TCTCUsersTests",
"name" : "TCTCUserStoreTests",
"pools" : [
],
"super" : "TCTCNoTdlibTestCase",
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tests
testMethodNotTooManyEmptyLines
testMethodNoConsecutiveEmptyLines

self methodsLinesDo: [:lines |
1 to: lines size -1 do: [:index |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"testLongMethods" : "JB 6/10/2021 22:45",
"testMethodHasEmptyLine" : "j 7/16/2020 12:29",
"testMethodNameIsLowerCase" : "JB 6/13/2021 10:53",
"testMethodNoConsecutiveEmptyLines" : "RS 6/23/2021 15:53",
"testMethodNoEmptyLineAtEnd" : "j 7/16/2020 12:32",
"testMethodNoTrailingWhitespaces" : "JB 6/10/2021 22:45",
"testMethodNoTwoWhitespacesNextToEachOther" : "js 6/13/2020 18:56",
"testMethodNotTooManyEmptyLines" : "js 6/13/2020 18:36",
"testMethodParamsHaveMeaningfulNames" : "RS 6/6/2021 11:58",
"testNoClassComments" : "js 6/13/2020 17:09",
"testNoDotAfterReturn" : "js 6/13/2020 18:09",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
user
mockUserPromises
mockUserStore

^ TCCUsers newFrom: {
^ TCCUserStore newFrom: {
self mockUser1 id -> (Promise new resolveWith: self mockUser1).
self mockUser2 id -> (Promise new resolveWith: self mockUser2)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"mockUserEvent" : "per 6/10/2021 19:30",
"mockUserJson1" : "per 6/10/2021 19:43",
"mockUserJson2" : "per 6/10/2021 19:29",
"mockUserPromises" : "per 6/15/2021 09:21",
"mockUserStore" : "RS 6/23/2021 16:00",
"mockUsers" : "TR 6/13/2021 15:15",
"writeMockImage" : "pk 6/19/2021 17:36" },
"instance" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ setUp

self core: (TCTUMockCore newWithTeleClient: TCTMMockTeleClient new).
self core chats: TCTMMocks mockChats.
self core users: TCTMMocks mockUserPromises.
self core users: TCTMMocks mockUserStore.
self wantsToTest: (TCUMain newWithCore: self core).
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"findByTextContent:in:" : "RS 5/31/2021 07:55",
"forceSaveScreenshotOf:as:in:" : "RS 5/26/2021 13:29",
"seeing:in:" : "per 6/15/2021 09:29",
"setUp" : "TR 6/13/2021 15:39",
"setUp" : "RS 6/23/2021 16:00",
"takeScreenshotOf:" : "JB 5/24/2021 16:21",
"tearDown" : "RS 6/25/2021 12:38",
"waitUntil:" : "RS 6/6/2021 13:00" } }

0 comments on commit 9557bb5

Please sign in to comment.