Skip to content

Commit

Permalink
chore: add prettier check to test (#166)
Browse files Browse the repository at this point in the history
Note: this change does add a format check to the test pipeline
  • Loading branch information
tjholm authored Mar 3, 2023
2 parents 060acb9 + 1aa0766 commit 7ae72ee
Show file tree
Hide file tree
Showing 58 changed files with 980 additions and 899 deletions.
46 changes: 24 additions & 22 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache Yarn Cache
uses: actions/cache@v2
with:
path: 'node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- name: Install modules
run: yarn --frozen-lockfile
- name: License Header Check
run: yarn license:header:check
- name: OSS License Whitelist Check
run: yarn license:check
- name: Check sources
run: |
yarn gen:proto
git add .
git diff --cached --quiet
- name: Build
run: yarn build
- name: Run tests
run: yarn coverage:upload
- name: Checkout
uses: actions/checkout@v2
- name: Cache Yarn Cache
uses: actions/cache@v2
with:
path: 'node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- name: Install modules
run: yarn --frozen-lockfile
- name: License Header Check
run: yarn license:header:check
- name: OSS License Whitelist Check
run: yarn license:check
- name: Check sources
run: |
yarn gen:proto
git add .
git diff --cached --quiet
- name: Check Formatting
run: yarn prettier:check
- name: Build
run: yarn build
- name: Run tests
run: yarn coverage:upload
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/src/gen
2 changes: 1 addition & 1 deletion src/api/documents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export * from './v0';
export * from './v0';
2 changes: 1 addition & 1 deletion src/api/documents/v0/collection-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class CollectionRef<T extends DocumentStructure> {
col.setName(this.name);

if (this.parent) {
col.setParent(this.parent["toWire"]());
col.setParent(this.parent['toWire']());
}

return col;
Expand Down
15 changes: 11 additions & 4 deletions src/api/documents/v0/document-ref.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
// limitations under the License.
import { Struct } from 'google-protobuf/google/protobuf/struct_pb';
import { DocumentServiceClient as GrpcKeyDocumentsClient } from '@nitric/api/proto/document/v1/document_grpc_pb';
import { DocumentGetResponse, Document } from '@nitric/api/proto/document/v1/document_pb';
import {
DocumentGetResponse,
Document,
} from '@nitric/api/proto/document/v1/document_pb';
import { InvalidArgumentError, UnimplementedError } from '../../errors';
import { Documents, documents } from './documents';

Expand Down Expand Up @@ -43,7 +46,9 @@ describe('Document Ref Tests', () => {

test('Then DocumentRef.Get should reject', async () => {
const doc = documentsClient.collection('test').doc('id');
await expect(doc.get()).rejects.toEqual(new UnimplementedError("UNIMPLEMENTED"));
await expect(doc.get()).rejects.toEqual(
new UnimplementedError('UNIMPLEMENTED')
);
});

test('The Grpc client for DocumentServiceClient.Put should have been called exactly once', () => {
Expand Down Expand Up @@ -120,7 +125,7 @@ describe('Document Ref Tests', () => {
doc.set({
name: 'test',
})
).rejects.toEqual(new UnimplementedError("UNIMPLEMENTED"));
).rejects.toEqual(new UnimplementedError('UNIMPLEMENTED'));
});

test('The Grpc client for DocumentServiceClient.Get should have been called exactly once', () => {
Expand Down Expand Up @@ -153,7 +158,9 @@ describe('Document Ref Tests', () => {

test('Then DocumentRef.Delete should reject', async () => {
const doc = documentsClient.collection('test').doc('id');
await expect(doc.delete()).rejects.toEqual(new UnimplementedError("UNIMPLEMENTED"));
await expect(doc.delete()).rejects.toEqual(
new UnimplementedError('UNIMPLEMENTED')
);
});

test('The Grpc client for DocumentServiceClient.Delete should have been called exactly once', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/api/documents/v0/document-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
DocumentSetRequest,
DocumentDeleteRequest,
} from '@nitric/api/proto/document/v1/document_pb';
import { DocumentServiceClient } from '@nitric/api/proto/document/v1/document_grpc_pb';
import { DocumentServiceClient } from '@nitric/api/proto/document/v1/document_grpc_pb';
import { fromGrpcError, InvalidArgumentError } from '../../errors';
import { CollectionRef } from './collection-ref';
import { MAX_COLLECTION_DEPTH } from './constants';
Expand Down Expand Up @@ -116,7 +116,7 @@ export class DocumentRef<T extends DocumentStructure> {

private toWire(): Key {
const key = new Key();
key.setCollection(this.parent["toWire"]());
key.setCollection(this.parent['toWire']());
key.setId(this.id);
return key;
}
Expand Down
14 changes: 9 additions & 5 deletions src/api/documents/v0/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import { Struct } from 'google-protobuf/google/protobuf/struct_pb';
import { PassThrough } from 'stream';
import { DocumentServiceClient as GrpcKeyDocumentsClient } from '@nitric/api/proto/document/v1/document_grpc_pb';
import {
DocumentQueryResponse,
import {
DocumentQueryResponse,
DocumentQueryStreamResponse,
Document,
ExpressionValue,
Collection,
Key
Key,
} from '@nitric/api/proto/document/v1/document_pb';
import { documents, Documents } from './documents';
import { DocumentSnapshot } from './document-snapshot';
Expand Down Expand Up @@ -126,7 +126,9 @@ describe('Query Tests', () => {

test('Then DocumentRef.Query should reject', async () => {
const query = documentsClient.collection('test').query();
await expect(query.fetch()).rejects.toEqual(new UnimplementedError("UNIMPLEMENTED"));
await expect(query.fetch()).rejects.toEqual(
new UnimplementedError('UNIMPLEMENTED')
);
});

test('The Grpc client for DocumentServiceClient.Query should have been called exactly once', () => {
Expand Down Expand Up @@ -239,7 +241,9 @@ describe('Query Tests', () => {
});
});

await expect(test).resolves.toEqual(new UnimplementedError("UNIMPLEMENTED"));
await expect(test).resolves.toEqual(
new UnimplementedError('UNIMPLEMENTED')
);
});

test('The Grpc client for DocumentServiceClient.QueryStream should have been called exactly once', () => {
Expand Down
19 changes: 11 additions & 8 deletions src/api/documents/v0/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,17 @@ export class Query<T extends DocumentStructure> {
transform: (result: DocumentQueryStreamResponse, encoding, callback) => {
const doc = result.getDocument();

callback(undefined, new DocumentSnapshot<T>(
new DocumentRef<T>(
this.documentClient,
this.collection,
doc.getKey().getId()
),
doc.getContent().toJavaScript() as T
));
callback(
undefined,
new DocumentSnapshot<T>(
new DocumentRef<T>(
this.documentClient,
this.collection,
doc.getKey().getId()
),
doc.getContent().toJavaScript() as T
)
);
},
});

Expand Down
14 changes: 7 additions & 7 deletions src/api/errors/aborted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

/**
* AbortedError
*
*
* The operation was aborted
*/
export class AbortedError extends Error {
constructor (message: string) {
super(message);
Object.setPrototypeOf(this, AbortedError.prototype);
}
}
export class AbortedError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, AbortedError.prototype);
}
}
14 changes: 7 additions & 7 deletions src/api/errors/already-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

/**
* AlreadyExistsError
*
*
* Client attempted to illegally create an entity that already exists
*/
export class AlreadyExistsError extends Error {
constructor (message: string) {
super(message);
Object.setPrototypeOf(this, AlreadyExistsError.prototype);
}
}
export class AlreadyExistsError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, AlreadyExistsError.prototype);
}
}
12 changes: 6 additions & 6 deletions src/api/errors/cancelled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

/**
* CancelledError
*
*
* Operation was cancelled (typically occurs client side)
*/
export class CancelledError extends Error {
constructor (message: string) {
super(message);
Object.setPrototypeOf(this, CancelledError.prototype);
}
}
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, CancelledError.prototype);
}
}
14 changes: 7 additions & 7 deletions src/api/errors/data-loss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

/**
* DataLossError
*
*
* Unrecoverable data loss or corruption
*/
export class DataLossError extends Error {
constructor (message: string) {
super(message);
Object.setPrototypeOf(this, DataLossError.prototype);
}
}
export class DataLossError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, DataLossError.prototype);
}
}
14 changes: 7 additions & 7 deletions src/api/errors/deadline-exceeded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

/**
* DeadlineExceededError
*
*
* Specified deadline was exceeded before the operation could complete
*/
export class DeadlineExceededError extends Error {
constructor (message: string) {
super(message);
Object.setPrototypeOf(this, DeadlineExceededError.prototype);
}
}
export class DeadlineExceededError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, DeadlineExceededError.prototype);
}
}
14 changes: 7 additions & 7 deletions src/api/errors/failed-precondition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

/**
* FailedPreconditionError
*
*
* Operation was rejected due to the system being not being
* in a state required for the requested operation.
*/
export class FailedPreconditionError extends Error {
constructor (message: string) {
super(message);
Object.setPrototypeOf(this, FailedPreconditionError.prototype);
}
}
export class FailedPreconditionError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, FailedPreconditionError.prototype);
}
}
Loading

0 comments on commit 7ae72ee

Please sign in to comment.