How to use getRelease method in mountebank

Best JavaScript code snippet using mountebank

releaseTests.js

Source:releaseTests.js Github

copy

Full Screen

...524 // Arrange 525 let expected = `tfs_release.json`;526 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);527 // Act528 release.getRelease({529 type: `asp`,530 target: `paas`,531 tfs: `http://tfs:8080/tfs/DefaultCollection`532 }, function (e, actual) {533 // Assert534 assert.equal(expected, actual);535 done(e);536 });537 }));538 it(`getRelease asp tfs 2017 paasslots`, sinonTest(function (done) {539 // Arrange 540 let expected = `vsts_release_slots.json`;541 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);542 // Act543 release.getRelease({544 type: `asp`,545 target: `paasslots`,546 tfs: `http://tfs:8080/tfs/DefaultCollection`547 }, function (e, actual) {548 // Assert549 assert.equal(expected, actual);550 done(e);551 });552 }));553 it(`getRelease asp vsts paasslots`, function (done) {554 // Arrange 555 let expected = `vsts_release_slots.json`;556 // Act557 release.getRelease({558 type: `asp`,559 target: `paasslots`,560 tfs: `vsts`561 }, function (e, actual) {562 // Assert563 assert.equal(expected, actual);564 done(e);565 });566 // Assert567 assert.equal(expected, actual);568 });569 it(`getRelease asp vsts paas`, function (done) {570 // Arrange 571 let expected = `vsts_release.json`;572 // Act573 release.getRelease({574 type: `asp`,575 target: `paas`,576 tfs: `vsts`577 }, function (e, actual) {578 // Assert579 assert.equal(expected, actual);580 done(e);581 });582 // Assert583 assert.equal(expected, actual);584 });585 it(`getRelease aspFull vsts paasslots`, function (done) {586 // Arrange 587 let expected = `vsts_release_slots.json`;588 // Act589 release.getRelease({590 type: `aspFull`,591 target: `paasslots`,592 tfs: `vsts`593 }, function (e, actual) {594 // Assert595 assert.equal(expected, actual);596 done(e);597 });598 });599 it(`getRelease aspFull vsts paas`, function (done) {600 // Arrange 601 let expected = `vsts_release.json`;602 // Act603 release.getRelease({604 type: `aspFull`,605 target: `paas`,606 tfs: `vsts`607 }, function (e, actual) {608 // Assert609 assert.equal(expected, actual);610 done(e);611 });612 });613 it(`getRelease asp tfs 2017 docker`, sinonTest(function (done) {614 // Arrange 615 let expected = `tfs_release_docker.json`;616 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);617 // Act618 release.getRelease({619 type: `asp`,620 target: `docker`,621 tfs: `http://tfs:8080/tfs/DefaultCollection`622 }, function (e, actual) {623 // Assert624 assert.equal(expected, actual);625 done(e);626 });627 }));628 it(`getRelease asp vsts docker`, function (done) {629 // Arrange 630 let expected = `vsts_release_docker.json`;631 // Act632 release.getRelease({633 type: `asp`,634 target: `docker`,635 tfs: `vsts`636 }, function (e, actual) {637 // Assert638 assert.equal(expected, actual);639 done(e);640 });641 });642 it(`getRelease asp tfs 2017 dockerpaas`, sinonTest(function (done) {643 // Arrange 644 let expected = `tfs_release_dockerpaas.json`;645 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);646 // Act647 release.getRelease({648 type: `asp`,649 target: `dockerpaas`,650 tfs: `http://tfs:8080/tfs/DefaultCollection`651 }, function (e, actual) {652 // Assert653 assert.equal(expected, actual);654 done(e);655 });656 }));657 it(`getRelease asp tfs 2017 dockerpaas no Load Test`, sinonTest(function (done) {658 // Arrange 659 let expected = `tfs_release_dockerpaas.json`;660 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);661 // Act662 release.getRelease({663 type: `asp`,664 target: `dockerpaas`,665 tfs: `http://tfs:8080/tfs/DefaultCollection`,666 removeloadTest: true667 }, function (e, actual) {668 // Assert669 assert.equal(expected, actual);670 done(e);671 });672 }));673 // The West Central US region of VSTS does not support Load Test.674 // So we need to create a release that does not use that task.675 it(`getRelease java vsts paas no Load Test`, function (done) {676 // Arrange 677 let expected = `vsts_release_noloadtest.json`;678 // Act679 release.getRelease({680 type: `java`,681 target: `paas`,682 tfs: `vsts`,683 removeloadTest: true684 }, function (e, actual) {685 // Assert686 assert.equal(expected, actual);687 done(e);688 });689 });690 it(`getRelease java vsts paas slots no Load Test`, function (done) {691 // Arrange 692 let expected = `vsts_release_slots.json`;693 // Act694 release.getRelease({695 type: `java`,696 target: `paasslots`,697 tfs: `vsts`,698 removeloadTest: true699 }, function (e, actual) {700 // Assert701 assert.equal(expected, actual);702 done(e);703 });704 });705 it(`getRelease java vsts docker no Load Test`, function (done) {706 // Arrange 707 let expected = `vsts_release_docker.json`;708 // Act709 release.getRelease({710 type: `java`,711 target: `docker`,712 tfs: `vsts`,713 removeloadTest: true714 }, function (e, actual) {715 // Assert716 assert.equal(expected, actual);717 done(e);718 });719 });720 it(`getRelease java vsts acilinux no Load Test`, function (done) {721 // Arrange 722 let expected = `vsts_release_acilinux.json`;723 // Act724 release.getRelease({725 type: `java`,726 target: `acilinux`,727 tfs: `vsts`,728 removeloadTest: true729 }, function (e, actual) {730 // Assert731 assert.equal(expected, actual);732 done(e);733 });734 });735 it(`getRelease asp vsts dockerpaas no Load Test`, function (done) {736 // Arrange 737 let expected = `vsts_release_dockerpaas_noloadtest.json`;738 // Act739 release.getRelease({740 type: `asp`,741 target: `dockerpaas`,742 tfs: `vsts`,743 removeloadTest: true744 }, function (e, actual) {745 // Assert746 assert.equal(expected, actual);747 done(e);748 });749 });750 it(`getRelease asp vsts dockerpaas`, function (done) {751 // Arrange 752 let expected = `vsts_release_dockerpaas.json`;753 // Act754 release.getRelease({755 type: `asp`,756 target: `dockerpaas`,757 tfs: `vsts`758 }, function (e, actual) {759 // Assert760 assert.equal(expected, actual);761 done(e);762 });763 });764 it(`getRelease asp tfs 2017 acilinux`, sinonTest(function (done) {765 // Arrange 766 let expected = `tfs_release_acilinux.json`;767 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);768 // Act769 release.getRelease({770 type: `asp`,771 target: `acilinux`,772 tfs: `http://tfs:8080/tfs/DefaultCollection`773 }, function (e, actual) {774 // Assert775 assert.equal(expected, actual);776 done(e);777 });778 }));779 it(`getRelease asp vsts acilinux`, function (done) {780 // Arrange 781 let expected = `vsts_release_acilinux.json`;782 // Act783 release.getRelease({784 type: `asp`,785 target: `acilinux`,786 tfs: `vsts`787 }, function (e, actual) {788 // Assert789 assert.equal(expected, actual);790 done(e);791 });792 });793 it(`getRelease java tfs 2017 dockerpaas`, sinonTest(function (done) {794 // Arrange 795 let expected = `tfs_release_dockerpaas.json`;796 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);797 // Act798 release.getRelease({799 type: `java`,800 target: `dockerpaas`,801 tfs: `http://tfs:8080/tfs/DefaultCollection`802 }, function (e, actual) {803 // Assert804 assert.equal(expected, actual);805 done(e);806 });807 }));808 it(`getRelease java vsts dockerpaas`, function (done) {809 // Arrange 810 let expected = `vsts_release_dockerpaas.json`;811 // Act812 release.getRelease({813 type: `java`,814 target: `dockerpaas`,815 tfs: `vsts`816 }, function (e, actual) {817 // Assert818 assert.equal(expected, actual);819 done(e);820 });821 });822 it(`getRelease java tfs 2017 acilinux`, sinonTest(function (done) {823 // Arrange 824 let expected = `tfs_release_acilinux.json`;825 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);826 // Act827 release.getRelease({828 type: `java`,829 target: `acilinux`,830 tfs: `http://tfs:8080/tfs/DefaultCollection`831 }, function (e, actual) {832 // Assert833 assert.equal(expected, actual);834 done(e);835 });836 }));837 it(`getRelease java vsts acilinux`, function (done) {838 // Arrange 839 let expected = `vsts_release_acilinux.json`;840 // Act841 release.getRelease({842 type: `java`,843 target: `acilinux`,844 tfs: `vsts`845 }, function (e, actual) {846 // Assert847 assert.equal(expected, actual);848 done(e);849 });850 });851 it(`getRelease java vsts docker`, function (done) {852 // Arrange 853 let expected = `vsts_release_docker.json`;854 // Act855 release.getRelease({856 type: `java`,857 target: `docker`,858 tfs: `vsts`859 }, function (e, actual) {860 // Assert861 assert.equal(expected, actual);862 done(e);863 });864 });865 it(`getRelease java vsts paasslots`, function (done) {866 // Arrange 867 let expected = `vsts_release_slots.json`;868 // Act869 release.getRelease({870 type: `java`,871 target: `paasslots`,872 tfs: `vsts`873 }, function (e, actual) {874 // Assert875 assert.equal(expected, actual);876 done(e);877 });878 });879 it(`getRelease java vsts paas`, function (done) {880 // Arrange 881 let expected = `vsts_release.json`;882 // Act883 release.getRelease({884 type: `java`,885 target: `paas`,886 tfs: `vsts`887 }, function (e, actual) {888 // Assert889 assert.equal(expected, actual);890 done(e);891 });892 });893 it(`getRelease node vsts dockerpaas`, function (done) {894 // Arrange 895 let expected = `vsts_release_dockerpaas.json`;896 // Act897 release.getRelease({898 type: `node`,899 target: `dockerpaas`,900 tfs: `vsts`,901 queue: `Hosted Linux Preview`902 }, function (e, actual) {903 // Assert904 assert.equal(expected, actual);905 done(e);906 });907 });908 it(`getRelease node vsts acilinux`, function (done) {909 // Arrange 910 let expected = `vsts_release_acilinux.json`;911 // Act912 release.getRelease({913 type: `node`,914 target: `acilinux`,915 tfs: `vsts`,916 queue: `Hosted Linux Preview`917 }, function (e, actual) {918 // Assert919 assert.equal(expected, actual);920 done(e);921 });922 });923 it(`getRelease node vsts docker`, function (done) {924 // Arrange 925 let expected = `vsts_release_docker.json`;926 // Act927 release.getRelease({928 type: `node`,929 target: `docker`,930 tfs: `vsts`931 }, function (e, actual) {932 // Assert933 assert.equal(expected, actual);934 done(e);935 });936 });937 it(`getRelease node vsts paasslots`, function (done) {938 // Arrange 939 let expected = `vsts_release_slots.json`;940 // Act941 release.getRelease({942 type: `node`,943 target: `paasslots`,944 tfs: `vsts`945 }, function (e, actual) {946 // Assert947 assert.equal(expected, actual);948 done(e);949 });950 });951 it(`getRelease node vsts paas`, function (done) {952 // Arrange 953 let expected = `vsts_release.json`;954 // Act955 release.getRelease({956 type: `node`,957 target: `paas`,958 tfs: `vsts`959 }, function (e, actual) {960 // Assert961 assert.equal(expected, actual);962 done(e);963 });964 });965 it(`getRelease powershell vsts`, function (done) {966 // Arrange 967 let expected = `vsts_release_powershell.json`;968 // Act969 release.getRelease({970 type: `powershell`,971 target: ``,972 tfs: `vsts`973 }, function (e, actual) {974 // Assert975 assert.equal(expected, actual);976 done(e);977 });978 });979 it(`getRelease node tfs 2017 acilinux`, sinonTest(function (done) {980 // Arrange 981 let expected = `tfs_release_acilinux.json`;982 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);983 // Act984 release.getRelease({985 type: `node`,986 target: `acilinux`,987 tfs: `http://tfs:8080/tfs/DefaultCollection`988 }, function (e, actual) {989 // Assert990 assert.equal(expected, actual);991 done(e);992 });993 }));994 it(`getRelease node tfs 2017 dockerpaas`, sinonTest(function (done) {995 // Arrange 996 let expected = `tfs_release_dockerpaas.json`;997 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);998 // Act999 release.getRelease({1000 type: `node`,1001 target: `dockerpaas`,1002 tfs: `http://tfs:8080/tfs/DefaultCollection`1003 }, function (e, actual) {1004 // Assert1005 assert.equal(expected, actual);1006 done(e);1007 });1008 }));1009 it(`getRelease node tfs 2018 dockerpaas`, sinonTest(function (done) {1010 // Arrange 1011 let expected = `tfs_2018_release_dockerpaas.json`;1012 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, true);1013 // Act1014 release.getRelease({1015 type: `node`,1016 target: `dockerpaas`,1017 tfs: `http://tfs:8080/tfs/DefaultCollection`1018 }, function (e, actual) {1019 // Assert1020 assert.equal(expected, actual);1021 done(e);1022 });1023 }));1024 it(`getRelease node tfs 2017 docker`, sinonTest(function (done) {1025 // Arrange 1026 let expected = `tfs_release_docker.json`;1027 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);1028 // Act1029 release.getRelease({1030 type: `node`,1031 target: `docker`,1032 tfs: `http://tfs:8080/tfs/DefaultCollection`1033 }, function (e, actual) {1034 // Assert1035 assert.equal(expected, actual);1036 done(e);1037 });1038 }));1039 it(`getRelease node tfs 2017 paas`, sinonTest(function (done) {1040 // Arrange 1041 let expected = `tfs_release.json`;1042 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, false);1043 // Act1044 release.getRelease({1045 type: `node`,1046 target: `paas`,1047 tfs: `http://tfs:8080/tfs/DefaultCollection`1048 }, function (e, actual) {1049 // Assert1050 assert.equal(expected, actual);1051 done(e);1052 });1053 }));1054 it(`getRelease node tfs 2018 paas`, sinonTest(function (done) {1055 // Arrange 1056 let expected = `tfs_2018_release.json`;1057 this.stub(util, `isTFSGreaterThan2017`).callsArgWith(2, null, true);1058 // Act1059 release.getRelease({1060 type: `node`,1061 target: `paas`,1062 tfs: `http://tfs:8080/tfs/DefaultCollection`1063 }, function (e, actual) {1064 // Assert1065 assert.equal(expected, actual);1066 done(e);1067 });1068 }));1069 it(`run with existing release should run without error`, sinonTest(function (done) {1070 // Arrange1071 stubs.findQueue(expectedAccount, `Default`, expectedToken, this);1072 stubs.findDockerServiceEndpoint(expectedAccount, expectedToken, this);1073 stubs.findDockerRegistryServiceEndpoint(expectedAccount, expectedToken, this);...

Full Screen

Full Screen

upload-release-asset.test.ts

Source:upload-release-asset.test.ts Github

copy

Full Screen

1import { upload, parseUploadUrl, canonicalName } from "../src/upload-release-asset";2test("Upload Release Asset", async () => {3 const uploadUrl =4 "https://example.com/repos/shogo82148/github-action-test/releases/23245222/assets";5 const uploadReleaseAsset = jest.fn().mockReturnValue({6 data: { browser_download_url: "http://example.com/download" },7 });8 const getRelease = jest.fn().mockReturnValue({9 data: {10 upload_url: uploadUrl,11 assets: [],12 },13 });14 const output = await upload({15 githubToken: "very-secret",16 uploadUrl: uploadUrl,17 assetPath: "__tests__/test/foo01.txt",18 assetName: "foo01.txt",19 assetContentType: "text/plain",20 overwrite: false,21 uploadReleaseAsset: uploadReleaseAsset,22 getRelease: getRelease,23 });24 // TODO: fix me25 // expect(uploadReleaseAsset).toHaveBeenCalledWith({26 // data: Buffer.from('foo\n'),27 // headers: {28 // 'content-length': 4,29 // 'content-type': 'text/plain'30 // },31 // name: 'foo01.txt',32 // url: 'http://example.com'33 // })34 expect(uploadReleaseAsset).toBeCalledTimes(1);35 expect(output.browser_download_url).toBe("http://example.com/download");36});37test("Upload Multiple Files", async () => {38 const uploadUrl =39 "https://example.com/repos/shogo82148/github-action-test/releases/23245222/assets";40 const uploadReleaseAsset = jest.fn().mockReturnValue({41 data: { browser_download_url: "http://example.com/download" },42 });43 const getRelease = jest.fn().mockReturnValue({44 data: {45 upload_url: uploadUrl,46 assets: [],47 },48 });49 const output = await upload({50 githubToken: "very-secret",51 uploadUrl: uploadUrl,52 assetPath: "__tests__/test/foo0[123].txt",53 assetName: "",54 assetContentType: "text/plain",55 overwrite: false,56 uploadReleaseAsset: uploadReleaseAsset,57 getRelease: getRelease,58 });59 // TODO: fix me60 // expect(uploadReleaseAsset).toHaveBeenCalledWith({61 // data: Buffer.from('foo\n'),62 // headers: {63 // 'content-length': 4,64 // 'content-type': 'text/plain'65 // },66 // name: 'foo01.txt',67 // url: 'http://example.com'68 // })69 // expect(uploadReleaseAsset).toHaveBeenCalledWith({70 // data: Buffer.from('foo\n'),71 // headers: {72 // 'content-length': 4,73 // 'content-type': 'text/plain'74 // },75 // name: 'foo02.txt',76 // url: 'http://example.com'77 // })78 // expect(uploadReleaseAsset).toHaveBeenCalledWith({79 // data: Buffer.from('foo\n'),80 // headers: {81 // 'content-length': 4,82 // 'content-type': 'text/plain'83 // },84 // name: 'foo03.txt',85 // url: 'http://example.com'86 // })87 expect(uploadReleaseAsset).toBeCalledTimes(3);88 expect(output.browser_download_url).toBe(89 "http://example.com/download\nhttp://example.com/download\nhttp://example.com/download"90 );91});92test("Guess Content Types", async () => {93 const uploadUrl =94 "https://example.com/repos/shogo82148/github-action-test/releases/23245222/assets";95 const uploadReleaseAsset = jest.fn().mockReturnValue({96 data: { browser_download_url: "http://example.com/download" },97 });98 const getRelease = jest.fn().mockReturnValue({99 data: {100 upload_url: uploadUrl,101 assets: [],102 },103 });104 const output = await upload({105 githubToken: "very-secret",106 uploadUrl: uploadUrl,107 assetPath: "__tests__/test/bar.*",108 assetName: "",109 assetContentType: "",110 overwrite: false,111 uploadReleaseAsset: uploadReleaseAsset,112 getRelease: getRelease,113 });114 // TODO: fix me115 // expect(uploadReleaseAsset).toHaveBeenCalledWith({116 // data: Buffer.from('bar\n'),117 // headers: {118 // 'content-length': 4,119 // 'content-type': 'image/jpeg'120 // },121 // name: 'bar.jpg',122 // url: 'http://example.com'123 // })124 // expect(uploadReleaseAsset).toHaveBeenCalledWith({125 // data: Buffer.from('bar\n'),126 // headers: {127 // 'content-length': 4,128 // 'content-type': 'image/png'129 // },130 // name: 'bar.png',131 // url: 'http://example.com'132 // })133 // expect(uploadReleaseAsset).toHaveBeenCalledWith({134 // data: Buffer.from('bar\n'),135 // headers: {136 // 'content-length': 4,137 // 'content-type': 'application/zip'138 // },139 // name: 'bar.zip',140 // url: 'http://example.com'141 // })142 expect(uploadReleaseAsset).toBeCalledTimes(3);143 expect(output.browser_download_url).toBe(144 "http://example.com/download\nhttp://example.com/download\nhttp://example.com/download"145 );146});147test("Guess Content Types", async () => {148 const uploadUrl =149 "https://example.com/repos/shogo82148/github-action-test/releases/23245222/assets";150 const uploadReleaseAsset = jest.fn().mockReturnValue({151 data: { browser_download_url: "http://example.com/download" },152 });153 const getRelease = jest.fn().mockReturnValue({154 data: {155 upload_url: uploadUrl,156 assets: [],157 },158 });159 const output = await upload({160 githubToken: "very-secret",161 uploadUrl: uploadUrl,162 assetPath: "__tests__/test/bar.*",163 assetName: "",164 assetContentType: "",165 overwrite: false,166 uploadReleaseAsset: uploadReleaseAsset,167 getRelease: getRelease,168 });169 // TODO: fix me170 // expect(uploadReleaseAsset).toHaveBeenCalledWith({171 // data: Buffer.from('bar\n'),172 // headers: {173 // 'content-length': 4,174 // 'content-type': 'image/jpeg'175 // },176 // name: 'bar.jpg',177 // url: 'http://example.com'178 // })179 // expect(uploadReleaseAsset).toHaveBeenCalledWith({180 // data: Buffer.from('bar\n'),181 // headers: {182 // 'content-length': 4,183 // 'content-type': 'image/png'184 // },185 // name: 'bar.png',186 // url: 'http://example.com'187 // })188 // expect(uploadReleaseAsset).toHaveBeenCalledWith({189 // data: Buffer.from('bar\n'),190 // headers: {191 // 'content-length': 4,192 // 'content-type': 'application/zip'193 // },194 // name: 'bar.zip',195 // url: 'http://example.com'196 // })197 expect(uploadReleaseAsset).toBeCalledTimes(3);198 expect(output.browser_download_url).toBe(199 "http://example.com/download\nhttp://example.com/download\nhttp://example.com/download"200 );201});202test("duplicated file names", async () => {203 const uploadUrl =204 "https://example.com/repos/shogo82148/github-action-test/releases/23245222/assets";205 const uploadReleaseAsset = jest.fn().mockReturnValue({206 data: { browser_download_url: "http://example.com/download" },207 });208 const getRelease = jest.fn().mockReturnValue({209 data: {210 upload_url: uploadUrl,211 assets: [],212 },213 });214 await expect(215 async () =>216 await upload({217 githubToken: "very-secret",218 uploadUrl: uploadUrl,219 assetPath: "__tests__/test/duplications/**",220 assetName: "",221 assetContentType: "",222 overwrite: false,223 uploadReleaseAsset: uploadReleaseAsset,224 getRelease: getRelease,225 })226 ).rejects.toThrow(/validation error/);227 expect(uploadReleaseAsset).not.toBeCalled();228});229test("uploading files already exists", async () => {230 const uploadUrl =231 "https://example.com/repos/shogo82148/github-action-test/releases/23245222/assets";232 const uploadReleaseAsset = jest.fn().mockReturnValue({233 data: { browser_download_url: "http://example.com/download" },234 });235 const getRelease = jest.fn().mockReturnValue({236 data: {237 upload_url: uploadUrl,238 assets: [239 {240 id: "1234",241 url: "http://example.com/download",242 name: "foo01.txt",243 },244 ],245 },246 });247 await expect(248 async () =>249 await upload({250 githubToken: "very-secret",251 uploadUrl: uploadUrl,252 assetPath: "__tests__/test/foo01.txt",253 assetName: "",254 assetContentType: "",255 overwrite: false,256 uploadReleaseAsset: uploadReleaseAsset,257 getRelease: getRelease,258 })259 ).rejects.toThrow(/validation error/);260 expect(uploadReleaseAsset).not.toBeCalled();261});262test("overwrite", async () => {263 const uploadUrl =264 "https://example.com/repos/shogo82148/github-action-test/releases/23245222/assets";265 const uploadReleaseAsset = jest.fn().mockReturnValue({266 data: { browser_download_url: "http://example.com/download" },267 });268 const getRelease = jest.fn().mockReturnValue({269 data: {270 upload_url: uploadUrl,271 assets: [272 {273 id: "1234",274 url: "http://example.com/download",275 name: "foo01.txt",276 },277 ],278 },279 });280 const deleteReleaseAsset = jest.fn();281 await upload({282 githubToken: "very-secret",283 uploadUrl: uploadUrl,284 assetPath: "__tests__/test/foo01.txt",285 assetName: "",286 assetContentType: "",287 overwrite: true,288 uploadReleaseAsset: uploadReleaseAsset,289 getRelease: getRelease,290 deleteReleaseAsset: deleteReleaseAsset,291 });292 expect(deleteReleaseAsset).toBeCalledWith({293 url: "http://example.com/download",294 githubToken: "very-secret",295 });296 expect(uploadReleaseAsset).toBeCalledTimes(1);297});298test("parseUploadUrl", () => {299 const release = parseUploadUrl(300 "https://example.com/repos/shogo82148/github-action-test/releases/23245222/assets"301 );302 expect(release.owner).toBe("shogo82148");303 expect(release.repo).toBe("github-action-test");304 expect(release.releaseId).toBe("23245222");305});306test("canonicalName", () => {307 expect(canonicalName("foo.txt")).toBe("foo.txt");308 expect(canonicalName("foo")).toBe("foo");309 expect(canonicalName("foo.")).toBe("default.foo");310 expect(canonicalName("foo..")).toBe("default.foo");311 expect(canonicalName(".foo")).toBe("default.foo");312 expect(canonicalName("..foo")).toBe("default.foo");313 expect(canonicalName(".foo.")).toBe("default.foo");314 expect(canonicalName("foo.txt.")).toBe("foo.txt");315 expect(canonicalName(".foo.txt")).toBe("default.foo.txt");316 expect(canonicalName(".foo.txt.")).toBe("default.foo.txt");317 expect(canonicalName("foo...txt")).toBe("foo.txt");318 expect(canonicalName(" !\"#$%&'()*+,-.txt")).toBe("+.-.txt");319 expect(canonicalName("foo/bar.txt")).toBe("foo.bar.txt");320 expect(canonicalName(":;<=>?@.txt")).toBe("@.txt");321 expect(canonicalName("[\\]^_`{|}~.txt")).toBe("_.txt");322 expect(canonicalName("あab.txt")).toBe("ab.txt");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var imposter = {3 {4 {5 is: {6 }7 }8 }9};10mb.create(imposter).then(function () {11 console.log('Imposter created');12});

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var port = 2525;3var imposters = {4 {5 {6 equals: {7 }8 }9 {10 is: {11 headers: {12 },13 body: JSON.stringify({status: 'success'})14 }15 }16 }17};18mb.create({port: port, allowInjection: true}, function (error, mbServer) {19 if (error) {20 console.log('error', error);21 }22 mbServer.post('/imposters', imposters, function (error, response) {23 if (error) {24 console.log('error', error);25 }26 console.log('response', response.body);27 mbServer.get('/imposters', function (error, response) {28 if (error) {29 console.log('error', error);30 }31 console.log('response', response.body);32 });33 });34});35var mb = require('mountebank');36var port = 2525;37var imposters = {38 {39 {40 equals: {41 }42 }43 {44 is: {45 headers: {46 },47 body: JSON.stringify({status: 'success'})48 }49 }50 }51};52mb.create({port: port,

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var options = {3};4mb.getRelease(options, function (error, release) {5 console.log(release);6});7{8}

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.getRelease(function (error, result) {3 console.log(result);4});5mb.getImposters(function (error, result) {6 console.log(result);7});8var imposter = {9 stubs: [{10 responses: [{11 is: {12 }13 }]14 }]15};16mb.createImposter(imposter, function (error, result) {17 console.log(result);18});19mb.deleteImposter(4545, function (error, result) {20 console.log(result);21});22mb.getImposter(4545, function (error, result) {23 console.log(result);24});25var stub = {26 responses: [{27 is: {28 }29 }]30};31mb.addStub(4545, stub, function (error, result) {32 console.log(result);33});34mb.deleteStub(4545, 0, function (error, result) {35 console.log(result);36});37mb.resetImposter(4545, function (error, result) {38 console.log(result);39});40mb.getLog(function (error, result) {41 console.log(result);42});43mb.deleteLog(function (error, result) {44 console.log(result);45});46mb.getConfig(function (error, result) {47 console.log(result);48});49var config = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2const port = 2525;3const imposterPort = 4545;4const protocol = 'http';5 {6 predicates: [{ equals: { path: '/api' } }],7 responses: [{ is: { body: 'response from imposter' } }],8 },9];10const imposter = { protocol, port: imposterPort, stubs };11mb.create({ port })12 .then(() => mb.post('/imposters', imposter))13 .then(() => mb.get('/imposters'))14 .then((response) => console.log(response.body))15 .then(() => mb.del('/imposters'))16 .then(() => mb.stop())17 .catch((e) => console.log(e));18{19 "scripts": {20 },21 "dependencies": {22 }23}

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2function getRelease() {3 var client = mb.createClient();4 client.get('/imposters', function (error, response) {5 if (error) {6 console.log(error);7 } else {8 console.log(response.body);9 }10 });11}12getRelease();

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var mbHelper = require('./mbHelper.js');3var mbPort = 2525;4var mbClient = mb.createClient({ port: mbPort, allowInjection: true });5var mbHelper = require('./mbHelper.js');6mbClient.getRelease(function (error, info) {7 if (error) {8 console.log(error);9 } else {10 console.log('Mountebank version: ' + info.version);11 }12});13mbClient.get('/', function (error, imposters) {14 if (error) {15 console.log(error);16 } else {17 console.log(imposters);18 }19});20var imposter = {21 {22 {23 is: {24 }25 }26 }27};28mbClient.post('/imposters', imposter, function (error, createdImposter) {29 if (error) {30 console.log(error);31 } else {32 console.log(createdImposter);33 }34});35mbClient.get('/imposters/2526', function (error, imposter) {36 if (error) {37 console.log(error);38 } else {39 console.log(imposter);40 }41});42mbClient.del('/imposters/2526', function (error, response) {43 if (error) {44 console.log(error);45 } else {46 console.log(response);47 }48});49mbClient.del('/', function (error, response) {50 if (error) {51 console.log(error);52 } else {53 console.log(response);54 }55});56mbClient.post('/imposters/2526/stubs', {57 {58 is: {59 }60 }61}, function (error, response) {62 if (error) {63 console.log(error);64 } else {65 console.log(response);66 }67});68mbClient.del('/imposters/2526

Full Screen

Using AI Code Generation

copy

Full Screen

1var mbHelper = require('./mountebankHelper.js');2 console.log(body);3});4var request = require('request');5var mountebankHelper = {6 getRelease: function(url, callback) {7 request(url, callback);8 }9};10module.exports = mountebankHelper;11{12 {13 {14 "is": {15 "headers": {16 },17 }18 }19 }20}21var assert = require('assert');22var mbHelper = require('./mountebankHelper.js');23 assert.equal(body, 'Hello World');24});

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var fs = require('fs');3var path = require('path');4function createMockService() {5 var imposters = fs.readFileSync(path.join(__dirname, 'imposters.json'), 'utf-8');6 var options = {7 headers: {8 },9 };10 request(options, function (error, response, body) {11 if (error) {12 console.log(error);13 } else {14 console.log(body);15 }16 });17}18function deleteMockService() {19 var options = {20 headers: {21 }22 };23 request(options, function (error, response, body) {24 if (error) {25 console.log(error);26 } else {27 console.log(body);28 }29 });30}31function getRelease() {32 var options = {33 headers: {34 }35 };36 request(options, function (error, response, body) {37 if (error) {38 console.log(error);39 } else {40 console.log(body);41 }42 });43}44function updateRelease() {45 var imposters = fs.readFileSync(path.join(__dirname, 'imposters.json'), 'utf-8');46 var options = {47 headers: {48 },49 };50 request(options, function (error, response, body) {51 if (error) {52 console.log(error);53 } else {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run mountebank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful