Starting tests for notebooks (creation timestamps).

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-01-24 10:36:54 -05:00
parent 2f9bef131f
commit 7784d99153
2 changed files with 46 additions and 1 deletions

View File

@ -81,9 +81,19 @@ GrafoscopioNode >> created: anObject [
created := anObject
]
{ #category : #accessing }
GrafoscopioNode >> earliestCreationDate [
| earliest |
earliest := self nodesWithCreationDates first created.
self nodesWithCreationDates do: [:node |
node created <= earliest ifTrue: [ earliest := node created ] ].
^ earliest
]
{ #category : #accessing }
GrafoscopioNode >> edited [
^ edited asDateAndTime
^ edited ifNotNil: [^ edited asDateAndTime ]
]
{ #category : #accessing }
@ -139,6 +149,16 @@ GrafoscopioNode >> nodesInPreorder: anObject [
nodesInPreorder := anObject
]
{ #category : #accessing }
GrafoscopioNode >> nodesWithCreationDates [
^ self nodesInPreorder select: [ :each | each created isNotNil ]
]
{ #category : #accessing }
GrafoscopioNode >> nodesWithEditionDates [
^ self nodesInPreorder select: [ :each | each edited isNotNil ]
]
{ #category : #accessing }
GrafoscopioNode >> parent [
^ parent
@ -149,6 +169,16 @@ GrafoscopioNode >> parent: anObject [
parent := anObject
]
{ #category : #accessing }
GrafoscopioNode >> populateTimestamps [
(self nodesInPreorder size = self nodesWithCreationDates size
and: [ self nodesInPreorder size = self nodesWithEditionDates size ])
ifTrue: [ ^ self nodesInPreorder ].
^ { self nodesWithCreationDates.
self nodesWithEditionDates}
]
{ #category : #accessing }
GrafoscopioNode >> printOn: aStream [
super printOn: aStream.

View File

@ -0,0 +1,15 @@
Class {
#name : #GrafoscopioNodeTest,
#superclass : #TestCase,
#category : #MiniDocs
}
{ #category : #accessing }
GrafoscopioNodeTest >> testEarliestCreationNode [
| notebook remoteNotebook offedingNodes |
remoteNotebook := 'https://mutabit.com/repos.fossil/documentaton/raw/a63598382?at=documentaton.ston'.
notebook := (STON fromString: remoteNotebook asUrl retrieveContents utf8Decoded) first parent.
offedingNodes := notebook nodesInPreorder select: [:node |
node created isNotNil and: [node created < notebook earliestCreationDate] ].
self assert: offedingNodes size equals: 0
]