Skip to content

Commit

Permalink
Merge pull request #28 from moosetechnology/newimportforgitmetric
Browse files Browse the repository at this point in the history
New import for git metric
  • Loading branch information
alkalinan authored Aug 21, 2024
2 parents 8794542 + c2427b6 commit d2ac4fd
Show file tree
Hide file tree
Showing 7 changed files with 743 additions and 53 deletions.
146 changes: 103 additions & 43 deletions src/GitLabHealth-Model-Analysis-Tests/GLHUserCatalogueTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ A GLHUserCatalogueTest is a test class for testing the behavior of GLHUserCatalo
Class {
#name : #GLHUserCatalogueTest,
#superclass : #TestCase,
#instVars : [
'catalogue'
],
#category : #'GitLabHealth-Model-Analysis-Tests'
}

{ #category : #running }
GLHUserCatalogueTest >> setUp [

catalogue := GLHUserCatalogue new.
]

{ #category : #test }
GLHUserCatalogueTest >> testAddSameUser [

| user catalogue |
catalogue := GLHUserCatalogue new.
| user |

user := GLHUser new
username: 'testUser';
Expand All @@ -27,24 +35,24 @@ GLHUserCatalogueTest >> testAddSameUser [
{ #category : #test }
GLHUserCatalogueTest >> testAddUser [

| user catalogue |
catalogue := GLHUserCatalogue new.
| user |


user := GLHUser new
username: 'testUser';
name: 'test user';
yourself.

catalogue addUser: user.
self assert: catalogue size equals: 1.
catalogue addUser: user.

self assert: catalogue size equals: 1
]

{ #category : #test }
GLHUserCatalogueTest >> testAddUserWithName [

| user catalogue |
catalogue := GLHUserCatalogue new.
| user |


user := GLHUser new
username: 'testUser';
Expand All @@ -64,30 +72,27 @@ GLHUserCatalogueTest >> testAddUserWithName [
{ #category : #test }
GLHUserCatalogueTest >> testAddUserWithNames [


| user catalogue |
catalogue := GLHUserCatalogue new.
| user |


user := GLHUser new
username: 'testUser';
name: 'test user';
yourself.

catalogue addUser: user withNames: {'toto' . 'tata' . 'titi'}.
catalogue addUser: user withNames: { 'toto'. 'tata'. 'titi' }.

self assert: (catalogue at: user) size equals: 5.
self assert: ((catalogue at: user) includes: 'toto') equals: true.
self assert: ((catalogue at: user) includes: 'tata') equals: true.
self
assert: ((catalogue at: user) includes: 'titi')
equals: true
self assert: ((catalogue at: user) includes: 'titi') equals: true
]

{ #category : #test }
GLHUserCatalogueTest >> testAddUsers [

| user1 user2 catalogue |
catalogue := GLHUserCatalogue new.
| user1 user2 |


user1 := GLHUser new
username: 'testUser1';
Expand All @@ -108,8 +113,8 @@ GLHUserCatalogueTest >> testAddUsers [
{ #category : #test }
GLHUserCatalogueTest >> testCollectUsernames [

| user1 user2 catalogue res |
catalogue := GLHUserCatalogue new.
| user1 user2 res |


user1 := GLHUser new
username: 'testUser1';
Expand All @@ -126,25 +131,23 @@ GLHUserCatalogueTest >> testCollectUsernames [


res := catalogue collectUsernames.

self assert: res size equals: 4.
self assert: (res at: 'testUser1') equals: user1.
self assert: (res at: 'testUser2') equals: user2.
self assert: (res at: 'test user1') equals: user1.
self assert: (res at: 'test user2') equals: user2.


self assert: res size equals: 4.
self assert: (res at: 'testUser1') equals: user1.
self assert: (res at: 'testUser2') equals: user2.
self assert: (res at: 'test user1') equals: user1.
self assert: (res at: 'test user2') equals: user2
]

{ #category : #tests }
GLHUserCatalogueTest >> testExportAndLoad [

| user json catalogue res |
| user json res |
user := GLHUser new
username: 'testUser';
name: 'test user';
yourself.
catalogue := GLHUserCatalogue new.


catalogue addUser: user.
json := catalogue exportToJson.
Expand All @@ -156,27 +159,28 @@ GLHUserCatalogueTest >> testExportAndLoad [
{ #category : #test }
GLHUserCatalogueTest >> testExportToJson [

| user user2 json catalogue res |
| user user2 json res |
user := GLHUser new
username: 'testUser';
name: 'test user';
id: 1;
yourself.
user2 := GLHUser new
username: 'testUser2';
name: 'test user2';
id: 2;
id: 1;
yourself.
catalogue := GLHUserCatalogue new.
user2 := GLHUser new
username: 'testUser2';
name: 'test user2';
id: 2;
yourself.

catalogue addUser: user; addUser: user2.

catalogue
addUser: user;
addUser: user2.
json := catalogue exportToJson.

res := (STONJSON fromString: json).
res := STONJSON fromString: json.
self assert: res size equals: catalogue size.
self assert: ((res at: 'test user2') at: #foundNames) size equals: 2 .
self assert: ((res at: 'test user') at: #foundNames) size equals: 2 .

self assert: ((res at: 'test user2') at: #foundNames) size equals: 2.
self assert: ((res at: 'test user') at: #foundNames) size equals: 2
]

{ #category : #tests }
Expand All @@ -190,3 +194,59 @@ GLHUserCatalogueTest >> testLoadFromJson [
self assert: (res searchUserWithName: 'Nicolas') isNotEmpty equals: true.
self assert: (res searchUserWithName: 'VERHAEGHE') isNotEmpty equals: true.
]

{ #category : #test }
GLHUserCatalogueTest >> testNamesAt [

| user |


user := GLHUser new
username: 'testUser';
name: 'test user';
yourself.

catalogue addUser: user withName: 'toto'.


self assert: (catalogue namesAt: user) size equals: 3.
self
assert: ((catalogue namesAt: user) includes: 'toto')
equals: true.
self
assert: ((catalogue namesAt: user) includes: 'testUser')
equals: true.
self
assert: ((catalogue namesAt: user) includes: 'test user')
equals: true
]

{ #category : #test }
GLHUserCatalogueTest >> testNamesAtChangingUser [

| user |


user := GLHUser new
username: 'testUser';
yourself.

user hash. " 114462615"

catalogue addUser: user withName: 'toto'.

user name: 'test User'.

user hash.

self assert: (catalogue namesAt: user) size equals: 3.
self
assert: ((catalogue namesAt: user) includes: 'toto')
equals: true.
self
assert: ((catalogue namesAt: user) includes: 'testUser')
equals: true.
self
assert: ((catalogue namesAt: user) includes: 'test user')
equals: true
]
Loading

0 comments on commit d2ac4fd

Please sign in to comment.