import fs from "fs" ; import path from "path" ; import { GitLabApiClient , MergeRequestResource , CommitResource , NoteResouce , DiscussionResource , } from "../gitlab-api-client" ; export class GitLabFixtureClient implements GitLabApiClient { constructor ( public fixtureName ) { } loadFixtue < T > ( methodName ) { const data = fs . readFileSync ( path . join ( __dirname , `../../test/fixtures/${ this . fixtureName }` , `${ methodName }.json` ) , "utf-8" ) ; return Promise . resolve ( JSON . parse ( data ) as T ) ; } getMergeRequests ( _params ) { return this . loadFixtue < MergeRequestResource [ ] > ( "getMergeRequests" ) ; } putMergeRequest ( _params ) { return this . loadFixtue < MergeRequestResource > ( "putMergeRequest" ) ; } getMergeRequestCommits ( _params ) { return this . loadFixtue < CommitResource [ ] > ( "getMergeRequestCommits" ) ; } getMergeRequestNotes ( _params ) { return this . loadFixtue < NoteResouce [ ] > ( "getMergeRequestNotes" ) ; } postMergeRequestNote ( _params ) { return this . loadFixtue < NoteResouce > ( "postMergeRequestNote" ) ; } putMergeRequestNote ( _params ) { return this . loadFixtue < NoteResouce > ( "putMergeRequestNote" ) ; } postMergeRequestDiscussion ( _params ) { return this . loadFixtue < DiscussionResource > ( "postMergeRequestDiscussion" ) ; } }