mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
os.getLastModified
Change-type: patch
This commit is contained in:
parent
f1e957f60f
commit
5793f03357
@ -102,12 +102,7 @@ export const isImageFresh = async (deviceType: string, version: string) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const balena = getBalenaSdk();
|
return true;
|
||||||
const lastModifiedDate = await balena.models.os.getLastModified(
|
|
||||||
deviceType,
|
|
||||||
version,
|
|
||||||
);
|
|
||||||
return lastModifiedDate < createdDate;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -343,60 +343,6 @@ describe('image-manager', function () {
|
|||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
this.utilsGetFileCreatedDate.restore();
|
this.utilsGetFileCreatedDate.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('given the file was created before the os last modified time', function () {
|
|
||||||
beforeEach(function () {
|
|
||||||
this.osGetLastModified = stub(balena.models.os, 'getLastModified');
|
|
||||||
this.osGetLastModified.returns(
|
|
||||||
Promise.resolve(new Date('2014-02-01T00:00:00.000Z')),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
this.osGetLastModified.restore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false', function () {
|
|
||||||
const promise = imageManager.isImageFresh('raspberry-pi', '1.2.3');
|
|
||||||
return expect(promise).to.eventually.be.false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('given the file was created after the os last modified time', function () {
|
|
||||||
beforeEach(function () {
|
|
||||||
this.osGetLastModified = stub(balena.models.os, 'getLastModified');
|
|
||||||
this.osGetLastModified.returns(
|
|
||||||
Promise.resolve(new Date('2013-01-01T00:00:00.000Z')),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
this.osGetLastModified.restore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true', function () {
|
|
||||||
const promise = imageManager.isImageFresh('raspberry-pi', '1.2.3');
|
|
||||||
return expect(promise).to.eventually.be.true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('given the file was created just at the os last modified time', function () {
|
|
||||||
beforeEach(function () {
|
|
||||||
this.osGetLastModified = stub(balena.models.os, 'getLastModified');
|
|
||||||
this.osGetLastModified.returns(
|
|
||||||
Promise.resolve(new Date('2014-00-01T00:00:00.000Z')),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
this.osGetLastModified.restore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false', function () {
|
|
||||||
const promise = imageManager.isImageFresh('raspberry-pi', '1.2.3');
|
|
||||||
return expect(promise).to.eventually.be.false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user