<commit_before>Class {
	#name : #MCMczInstallerTest,
	#superclass : #MCTestCase,
	#instVars : [
		'expected',
		'diff'
	],
	#category : #'Monticello-Tests-IO'
}

{ #category : #'as yet unclassified' }
MCMczInstallerTest class >> isAbstract [
	^ (Smalltalk hasClassNamed: #MczInstaller) not
		
]

{ #category : #'as yet unclassified' }
MCMczInstallerTest class >> suite [
	^ (Smalltalk hasClassNamed: #MczInstaller)
		ifTrue: [ super suite ]
		ifFalse: [ self classForTestSuite new name: self name asString ]
]

{ #category : #'as yet unclassified' }
MCMczInstallerTest >> assertDict: dict matchesInfo: info [
	#(name id message date time author)
		do: [:sel |  (info perform: sel) ifNotNil: [:i | dict at: sel ifPresent: [:d | self assert: i = d]]].
	info ancestors 
			with: (dict at: #ancestors) 
			do: [:i :d | self assertDict: d matchesInfo: i]
]

{ #category : #'as yet unclassified' }
MCMczInstallerTest >> assertNoChange [
	| actual |
	actual := MCSnapshotResource takeSnapshot.
	diff := actual patchRelativeToBase: expected snapshot.
	self assert: diff isEmpty
]

{ #category : #'as yet unclassified' }
MCMczInstallerTest >> assertVersionInfoPresent [
	| dict info |
	dict := MczInstaller versionInfo at: self mockPackage name.
	info := expected info.
	self assertDict: dict matchesInfo: info.
]

{ #category : #'as yet unclassified' }
MCMczInstallerTest >> deleteFile [
	self fileName asFileReference ensureDelete
]

{ #category : #'as yet unclassified' }
MCMczInstallerTest >> fileName [
	^ 'InstallerTest.mcz'
]

{ #category : #'as yet unclassified' }
MCMczInstallerTest >> fileStream [
	^ FileStream forceNewFileNamed: self fileName.
]

{ #category : #running }
MCMczInstallerTest >> setUp [
	super setUp.
	expected := self mockVersion.
	self change: #one toReturn: 2.
]

{ #category : #running }
MCMczInstallerTest >> tearDown [
	expected snapshot updatePackage: self mockPackage.
	self deleteFile.
]

{ #category : #'as yet unclassified' }
MCMczInstallerTest >> testInstallFromFile [
	MCMczWriter fileOut: expected on: self fileStream.
	MczInstaller installFileNamed: self fileName.
	self assertNoChange.
]

{ #category : #'as yet unclassified' }
MCMczInstallerTest >> testInstallFromStream [
	| stream |
	stream := RWBinaryOrTextStream on: String new.
	MCMczWriter fileOut: expected on: stream.
	MczInstaller installStream: stream reset.
	self assertNoChange.
	self assertVersionInfoPresent.
	
]<commit_msg>classify methods<commit_after>Class {
	#name : #MCMczInstallerTest,
	#superclass : #MCTestCase,
	#instVars : [
		'expected',
		'diff'
	],
	#category : #'Monticello-Tests-IO'
}

{ #category : #testing }
MCMczInstallerTest class >> isAbstract [
	^ (Smalltalk hasClassNamed: #MczInstaller) not
		
]

{ #category : #accessing }
MCMczInstallerTest class >> suite [
	^ (Smalltalk hasClassNamed: #MczInstaller)
		ifTrue: [ super suite ]
		ifFalse: [ self classForTestSuite new name: self name asString ]
]

{ #category : #assertions }
MCMczInstallerTest >> assertDict: dict matchesInfo: info [
	#(name id message date time author)
		do: [:sel |  (info perform: sel) ifNotNil: [:i | dict at: sel ifPresent: [:d | self assert: i = d]]].
	info ancestors 
			with: (dict at: #ancestors) 
			do: [:i :d | self assertDict: d matchesInfo: i]
]

{ #category : #assertions }
MCMczInstallerTest >> assertNoChange [
	| actual |
	actual := MCSnapshotResource takeSnapshot.
	diff := actual patchRelativeToBase: expected snapshot.
	self assert: diff isEmpty
]

{ #category : #assertions }
MCMczInstallerTest >> assertVersionInfoPresent [
	| dict info |
	dict := MczInstaller versionInfo at: self mockPackage name.
	info := expected info.
	self assertDict: dict matchesInfo: info.
]

{ #category : #utilities }
MCMczInstallerTest >> deleteFile [
	self fileName asFileReference ensureDelete
]

{ #category : #accessing }
MCMczInstallerTest >> fileName [
	^ 'InstallerTest.mcz'
]

{ #category : #accessing }
MCMczInstallerTest >> fileStream [
	^ FileStream forceNewFileNamed: self fileName.
]

{ #category : #running }
MCMczInstallerTest >> setUp [
	super setUp.
	expected := self mockVersion.
	self change: #one toReturn: 2.
]

{ #category : #running }
MCMczInstallerTest >> tearDown [
	expected snapshot updatePackage: self mockPackage.
	self deleteFile.
]

{ #category : #tests }
MCMczInstallerTest >> testInstallFromFile [
	MCMczWriter fileOut: expected on: self fileStream.
	MczInstaller installFileNamed: self fileName.
	self assertNoChange.
]

{ #category : #tests }
MCMczInstallerTest >> testInstallFromStream [
	| stream |
	stream := RWBinaryOrTextStream on: String new.
	MCMczWriter fileOut: expected on: stream.
	MczInstaller installStream: stream reset.
	self assertNoChange.
	self assertVersionInfoPresent.
	
]
{'fraction_non_alphanumeric': 0.11181702668360864, 'fraction_numerical': 0.00042354934349851756, 'mean_word_length': 4.731796116504855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '247426', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1582, 'n_words': 429}