From 7784d99153eade4267b99b3b76b964ea7a4b11e7 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 24 Jan 2023 10:36:54 -0500 Subject: [PATCH] Starting tests for notebooks (creation timestamps). --- src/MiniDocs/GrafoscopioNode.class.st | 32 ++++++++++++++++++++++- src/MiniDocs/GrafoscopioNodeTest.class.st | 15 +++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/MiniDocs/GrafoscopioNodeTest.class.st diff --git a/src/MiniDocs/GrafoscopioNode.class.st b/src/MiniDocs/GrafoscopioNode.class.st index 68f5379..7e9274b 100644 --- a/src/MiniDocs/GrafoscopioNode.class.st +++ b/src/MiniDocs/GrafoscopioNode.class.st @@ -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. diff --git a/src/MiniDocs/GrafoscopioNodeTest.class.st b/src/MiniDocs/GrafoscopioNodeTest.class.st new file mode 100644 index 0000000..f05c0d7 --- /dev/null +++ b/src/MiniDocs/GrafoscopioNodeTest.class.st @@ -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 +]