File tree Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,7 @@ import IDrive from '../gateways/IDrive'
5
5
import IBlobRepository from '../repositories/IBlobRepository'
6
6
import IObjectRepository from '../repositories/IObjectRepository'
7
7
8
- interface Params {
9
- path : string
10
- }
11
-
12
- export default class HashFileUseCase {
8
+ export default class HashEntryService {
13
9
constructor (
14
10
private readonly drive : IDrive ,
15
11
private readonly objectRepository : IObjectRepository ,
@@ -43,7 +39,7 @@ export default class HashFileUseCase {
43
39
44
40
const isFile = await this . drive . isFile ( entryPath )
45
41
46
- const result = await this . execute ( { path : entryPath } )
42
+ const result = await this . hashEntry ( entryPath )
47
43
48
44
treeEntries . push ( {
49
45
path : entry ,
@@ -57,7 +53,7 @@ export default class HashFileUseCase {
57
53
return this . objectRepository . save ( tree )
58
54
}
59
55
60
- public async execute ( { path } : Params ) {
56
+ public async hashEntry ( path : string ) {
61
57
if ( ! ( await this . drive . exists ( path ) ) ) {
62
58
throw new BaseException ( 'File not found' )
63
59
}
Original file line number Diff line number Diff line change 1
1
import { test , expect , describe } from 'vitest'
2
2
import InMemoryDrive from '../__tests__/InMemoryDrive'
3
3
import HelperService from '../services/HelperService'
4
- import HashFileUseCase from './HashFileUseCase '
4
+ import HashEntryUseCase from './HashEntryUseCase '
5
5
import InMemoryHash from '../__tests__/InMemoryHash'
6
6
import LocalObjectRepository from '../repositories/implementations/LocalObjectRepository'
7
7
import LocalBlobRepository from '../repositories/implementations/LocalBlobRepository'
@@ -11,9 +11,9 @@ const hash = new InMemoryHash()
11
11
const objectRepository = new LocalObjectRepository ( drive , hash )
12
12
const blobRepository = new LocalBlobRepository ( drive , hash )
13
13
14
- const useCase = new HashFileUseCase ( drive , objectRepository , blobRepository )
14
+ const useCase = new HashEntryUseCase ( drive , objectRepository , blobRepository )
15
15
16
- describe ( 'HashFileUseCase ' , ( ) => {
16
+ describe ( 'HashEntryUseCase ' , ( ) => {
17
17
test ( 'should save a file object' , async ( ) => {
18
18
const messageContent = HelperService . encode ( 'Hello World!' )
19
19
Original file line number Diff line number Diff line change
1
+ import IDrive from '../gateways/IDrive'
2
+ import IBlobRepository from '../repositories/IBlobRepository'
3
+ import IObjectRepository from '../repositories/IObjectRepository'
4
+ import HashEntryService from '../services/HashEntryService'
5
+
6
+ interface Params {
7
+ path : string
8
+ }
9
+
10
+ export default class HashEntryUseCase {
11
+ constructor (
12
+ private readonly drive : IDrive ,
13
+ private readonly objectRepository : IObjectRepository ,
14
+ private readonly blobRepository : IBlobRepository
15
+ ) { }
16
+
17
+ public async execute ( { path } : Params ) {
18
+ const service = new HashEntryService ( this . drive , this . objectRepository , this . blobRepository )
19
+
20
+ return await service . hashEntry ( path )
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments