Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
Microservices
query-service
Commits
50b412ab
Commit
50b412ab
authored
3 weeks ago
by
Marcos Pieras
Browse files
Options
Downloads
Patches
Plain Diff
test: first version
parent
e585b3a1
Branches
test/diffCheck2
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#146072
passed
3 weeks ago
Stage: tag-release
Stage: get-release-tag
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/readers/diffCheck.ts
+7
-1
7 additions, 1 deletion
src/readers/diffCheck.ts
src/readers/testInsights/diffCheck.test.ts
+64
-0
64 additions, 0 deletions
src/readers/testInsights/diffCheck.test.ts
with
71 additions
and
1 deletion
src/readers/diffCheck.ts
+
7
−
1
View file @
50b412ab
...
...
@@ -5,6 +5,10 @@ import type { GraphQueryResultMetaFromBackend } from 'ts-common/src/model/webSoc
import
{
ums
}
from
'
../variables
'
;
import
type
{
InsightModel
}
from
'
ts-common
'
;
export
const
compareHashedQueryResults
=
(
previousHash
:
string
|
null
,
currentHash
:
string
):
boolean
=>
{
return
!
previousHash
||
!
hashIsEqual
(
currentHash
,
previousHash
);
};
export
const
diffCheck
=
async
(
insight
:
InsightModel
,
ss
:
SaveState
,
...
...
@@ -20,7 +24,9 @@ export const diffCheck = async (
});
log
.
debug
(
'
Comparing hash values from current and previous query
'
);
const
changed
=
!
previousQueryResult
||
!
hashIsEqual
(
queryResultHash
,
previousQueryResult
);
const
changed
=
compareHashedQueryResults
(
previousQueryResult
,
queryResultHash
);
insight
.
status
||=
changed
;
log
.
debug
(
'
Updated node and edge ids in SaveState
'
);
...
...
This diff is collapsed.
Click to expand it.
src/readers/testInsights/diffCheck.test.ts
0 → 100644
+
64
−
0
View file @
50b412ab
import
{
expect
,
test
,
describe
,
it
}
from
'
bun:test
'
;
import
type
{
GraphQueryResultMetaFromBackend
}
from
'
ts-common
'
;
import
{
hashDictionary
,
hashIsEqual
}
from
'
../../utils/hashing
'
;
import
{
compareHashedQueryResults
}
from
'
../diffCheck
'
;
describe
(
'
Hash Comparison Tests
'
,
()
=>
{
it
(
'
should detect different hashes for different graph structures
'
,
()
=>
{
// First query result
const
query1
:
GraphQueryResultMetaFromBackend
=
{
nodes
:
[{
_id
:
'
node1
'
},
{
_id
:
'
node2
'
}],
edges
:
[{
_id
:
'
edge1
'
}],
}
as
GraphQueryResultMetaFromBackend
;
// Second query result with different structure
const
query2
:
GraphQueryResultMetaFromBackend
=
{
nodes
:
[{
_id
:
'
node1
'
},
{
_id
:
'
node2
'
},
{
_id
:
'
node3
'
}],
edges
:
[{
_id
:
'
edge1
'
},
{
_id
:
'
edge2
'
}],
}
as
GraphQueryResultMetaFromBackend
;
const
hash1
=
hashDictionary
({
nodes
:
query1
.
nodes
.
map
(
node
=>
node
.
_id
),
edges
:
query1
.
edges
.
map
(
edge
=>
edge
.
_id
),
});
const
hash2
=
hashDictionary
({
nodes
:
query2
.
nodes
.
map
(
node
=>
node
.
_id
),
edges
:
query2
.
edges
.
map
(
edge
=>
edge
.
_id
),
});
// Test direct hash comparison
expect
(
hashIsEqual
(
hash1
,
hash2
)).
toBe
(
false
);
// Test using compareHashedQueryResults
expect
(
compareHashedQueryResults
(
hash1
,
hash2
)).
toBe
(
true
);
});
it
(
'
should detect identical hashes for same graph structures
'
,
()
=>
{
const
query1
=
{
nodes
:
[{
_id
:
'
node1
'
},
{
_id
:
'
node2
'
}],
edges
:
[{
_id
:
'
edge1
'
}],
}
as
GraphQueryResultMetaFromBackend
;
const
query2
=
{
nodes
:
[{
_id
:
'
node1
'
},
{
_id
:
'
node2
'
}],
edges
:
[{
_id
:
'
edge1
'
}],
}
as
GraphQueryResultMetaFromBackend
;
const
hash1
=
hashDictionary
({
nodes
:
query1
.
nodes
.
map
(
node
=>
node
.
_id
),
edges
:
query1
.
edges
.
map
(
edge
=>
edge
.
_id
),
});
const
hash2
=
hashDictionary
({
nodes
:
query2
.
nodes
.
map
(
node
=>
node
.
_id
),
edges
:
query2
.
edges
.
map
(
edge
=>
edge
.
_id
),
});
// Test direct hash comparison
expect
(
hashIsEqual
(
hash1
,
hash2
)).
toBe
(
true
);
// Test using compareHashedQueryResults
expect
(
compareHashedQueryResults
(
hash1
,
hash2
)).
toBe
(
false
);
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment