Skip to content

Instantly share code, notes, and snippets.

@aasumitro
Created July 27, 2023 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aasumitro/4404506bed46a25529d722f1ff944267 to your computer and use it in GitHub Desktop.
Save aasumitro/4404506bed46a25529d722f1ff944267 to your computer and use it in GitHub Desktop.
func (handler *designerHandler) Notify(ctx *fiber.Ctx) error {
ctx.Set(fiber.HeaderContentType, "text/event-stream")
ctx.Set(fiber.HeaderCacheControl, "no-cache")
ctx.Set(fiber.HeaderConnection, "keep-alive")
ctx.Set(fiber.HeaderTransferEncoding, "chunked")
ctx.Context().SetBodyStreamWriter(func(w *bufio.Writer) {
for {
if handler.q.Length() == 0 {
time.Sleep(time.Second * 1)
continue
}
handler.mu.Lock()
item := handler.q.Remove()
if item == nil {
log.Printf("ERR_QUEUE: failed to get message\n")
handler.mu.Unlock()
return
}
if _, err := fmt.Fprintf(w, "data: %s\n\n", *item); err != nil {
log.Printf("ERR_WRITE: %v\n", err)
handler.mu.Unlock()
return
}
if err := w.Flush(); err != nil {
log.Printf("ERR_FLUSH: %v\n", err)
handler.mu.Unlock()
return
}
handler.mu.Unlock()
}
})
return nil
}
let sseSource = null;
const apiURL = "http://localhost:3000/designer";
const sseURL = `${apiURL}/notifications`;
const confURL = `${apiURL}/configurations`;
document.addEventListener('DOMContentLoaded', () => {
if(typeof(EventSource) !== "undefined") {
sseSource = new EventSource(sseURL);
sseSource.addEventListener("message", function(event) {
const data = event.data;
showNotificationDialog(data);
});
sseSource.addEventListener('error', function() {
if (sseSource.readyState === EventSource.CLOSED) {
sseSource = new EventSource(sseURL);
}
});
} else {
alert("Sorry, your browser does not support server-sent events...");
}
document.getElementById('copyright').textContent = `
COPYRIGHT © ${new Date().getFullYear()} SKILLEDIN PTE. LTD. ALL RIGHTS RESERVED.
`;
});
@aasumitro
Copy link
Author

<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="icon" href="https://stgreenskills001.blob.core.windows.net/greenskills-recruiter-assets-production/avatar-placeholder.png">
        <script src="https://cdn.tailwindcss.com"></script>
        <script>
            tailwind.config = {
              theme: {
                screens: {
                  'nd': {'min': '1025px'},
                  'sm': {'min': '640px', 'max': '767px'},
                  'md': {'min': '768px', 'max': '1023px'},
                  'lg': {'min': '1024px', 'max': '1279px'},
                  'xl': {'min': '1280px', 'max': '1535px'},
                  '2xl': {'min': '1536px'},
                },
              }
            }
        </script>
        <title>Home - SkilledIn API Proxy/Gateway Designer </title>
    </head>
    <body class="w-min-full h-min-full">
        <header class="flex flex-col items-center mx-auto my-12">
            <img class="mb-4" src="https://stgreenskills001.blob.core.windows.net/greenskills-recruiter-assets-production/avatar-placeholder.png" alt="logo">
            <h1 class="text-3xl font-extrabold">SkilledIn</h1>
            <h3 class="text-xl font-light tracking-wider"> API Gateway Designer</h3>
        </header>

        <main class="container mx-auto px-12">
            <div class="nd:hidden text-center py-72">
                Screen Size Not Supported <br/> (min: 1025px)
            </div>

            <div class="hidden nd:flex flex-col relative space-y-4">
                <div class="flex flex-row justify-between items-center">
                    <h1 class="text-3xl font-extrabold">Service URLs</h1>
                    <button class="flex items-center bg-gray-200 hover:bg-gray-600 p-2 text-gray-500 hover:text-white rounded-md ml-auto">
                        <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
                            <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
                        </svg>
                    </button>
                </div>
                <div class="animate-pulse p-4 bg-gray-100 rounded-lg">
                    <div class="flex-1 flex justify-between items-center">
                        <div class="flex flex-row items-center space-x-4">
                            <span class="bg-gray-200 rounded w-28 h-10"></span>
                            <span class="bg-gray-200 rounded w-96 h-4"></span>
                        </div>
                        <div class="flex flex-row space-x-2">
                            <span class="bg-gray-200 rounded w-8 h-8"></span>
                            <span class="bg-gray-200 rounded w-8 h-8"></span>
                        </div>
                    </div>
                </div>
                <div class="p-4 bg-gray-100 rounded-lg">
                    <div class="flex-1 flex justify-between items-center">
                        <div class="flex flex-row items-center space-x-4">
                            <h3 class="text-1xl font-bold p-2 text-gray-600 bg-gray-200 rounded">REFERENCE</h3>
                            <p class="text-sm font-normal">https://wapp-gs-references-api-sea-001.azurewebsites.net</p>
                        </div>
                        <div class="flex flex-row space-x-2">
                            <button class="flex items-center justify-center rounded-lg bg-gray-200 hover:bg-gray-600 text-black hover:text-white w-8 h-8">
                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" />
                                </svg>
                            </button>
                            <button class="flex items-center justify-center rounded-lg bg-gray-200 hover:bg-gray-600 w-8 h-8 text-black hover:text-white">
                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
                                </svg>
                            </button>
                        </div>
                    </div>
                </div>
                <div class="p-4 bg-gray-100 rounded-lg">
                    <div class="flex-1 flex justify-between items-center">
                        <div class="flex flex-row items-center space-x-4">
                            <h3 class="text-1xl font-bold p-2 text-gray-700 bg-gray-200 rounded">RECRUITER</h3>
                            <p class="text-sm font-normal">https://wapp-greenskills-recruiter-api-prod-sea--staging.azurewebsites.net</p>
                        </div>
                        <div class="flex flex-row space-x-2">
                            <button class="flex items-center justify-center rounded-lg bg-gray-200 hover:bg-gray-600 text-black hover:text-white w-8 h-8">
                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" />
                                </svg>
                            </button>
                            <button class="flex items-center justify-center rounded-lg  bg-gray-200 hover:bg-gray-600 w-8 h-8 text-black hover:text-white">
                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
                                </svg>
                            </button>
                        </div>
                    </div>
                </div>
                <div class="p-4 bg-gray-100 rounded-lg">
                    <h3 class="text-md font-semibold mb-2 text-gray-600">Add New Service</h3>
                    <div class="flex flex-row gap-4">
                        <label for="name" class="block text-xs font-medium leading-6 text-gray-900 w-2/6">
                            Name
                            <input type="text" name="name" id="name" autocomplete="name" class="block w-full rounded-md border-0 py-1.5 px-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
                        </label>
                        <label for="url" class="block text-xs font-medium leading-6 text-gray-900 w-4/6">
                            URL
                            <input type="text" name="url" id="url" autocomplete="url" class="block w-full rounded-md border-0 py-1.5 px-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
                        </label>
                        <button class="flex items-center justify-center rounded-lg bg-gray-200 hover:bg-gray-600 text-black hover:text-white w-16 h-[36px] mt-6">
                            Save
                        </button>
                        <button class="flex items-center justify-center rounded-lg bg-gray-200 hover:bg-gray-600 text-black hover:text-white w-20 h-[36px] mt-6">
                            Delete
                        </button>
                    </div>
                </div>
                <button class="flex items-center bg-blue-600 hover:bg-blue-700 py-2 px-4 gap-2 text-white rounded-lg ml-auto" onclick="fetchConfigurationData()">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" />
                    </svg>
                    Add New Service
                </button>
            </div>

            <hr class="hidden nd:block my-16">

            <div class="hidden nd:flex flex-col relative space-y-4">
                <div class="flex flex-row justify-between items-center">
                    <h1 class="text-3xl font-extrabold">Service Endpoints</h1>
                    <div class="flex gap-2">
                        <button class="flex items-center bg-gray-100 hover:bg-gray-500 p-2 text-gray-500 hover:text-white rounded-md ml-auto">
                            <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M10.5 6h9.75M10.5 6a1.5 1.5 0 11-3 0m3 0a1.5 1.5 0 10-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-9.75 0h9.75" />
                            </svg>
                        </button>
                        <button class="flex items-center bg-gray-100 hover:bg-gray-500 p-2 text-gray-500 hover:text-white rounded-md ml-auto">
                            <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
                            </svg>
                        </button>
                    </div>
                </div>
                <div class="animate-pulse p-4 bg-gray-100 rounded-lg">
                    <div class="flex-1 flex justify-between items-center">
                        <div class="flex flex-row items-center space-x-4">
                            <span class="bg-gray-200 rounded w-28 h-10"></span>
                            <span class="bg-gray-200 rounded-full w-12 h-8"></span>
                            <span class="bg-gray-200 rounded w-48 h-4"></span>
                        </div>
                        <div class="flex flex-row space-x-2">
                            <span class="bg-gray-200 rounded w-8 h-8"></span>
                            <span class="bg-gray-200 rounded w-8 h-8"></span>
                        </div>
                    </div>
                </div>
                <div class="p-4 bg-gray-100 rounded-lg">
                    <div class="flex-1 flex justify-between items-center">
                        <div class="flex flex-row items-center space-x-4">
                            <h3 class="text-1xl font-bold p-2 text-gray-600 bg-gray-200 rounded">REFERENCE</h3>
                            <div class="flex items-center gap-2">
                                <h5 class="text-sm py-[2px] px-[8px] font-semibold text-white bg-blue-500 rounded-full">GET</h5>
                                <p class="text-xs font-light text-muted">/api/v1/critical-skills</p>
                            </div>
                        </div>
                        <div class="flex flex-row space-x-2">
                            <button class="flex items-center justify-center rounded-lg bg-gray-200 hover:bg-gray-600 text-black hover:text-white w-8 h-8">
                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125" />
                                </svg>
                            </button>
                        </div>
                    </div>
                </div>
                <div class="p-4 bg-gray-100 rounded-lg">
                    <div class="flex-1 flex justify-between items-center">
                        <div class="flex flex-row items-center space-x-4">
                            <h3 class="text-1xl font-bold p-2 text-gray-600 bg-gray-200 rounded">RECRUITER</h3>
                            <div class="flex items-center gap-2">
                                <h5 class="text-sm py-[2px] px-[8px] font-semibold text-white bg-green-500 rounded-full">POST</h5>
                                <p class="text-xs font-light text-muted">/api/v1/job-boards/apply</p>
                            </div>
                        </div>
                        <div class="flex flex-row space-x-2">
                            <button class="flex items-center justify-center rounded-lg bg-gray-200 hover:bg-gray-600 text-black hover:text-white w-8 h-8">
                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125" />
                                </svg>
                            </button>
                        </div>
                    </div>
                </div>
                <div class="p-4 bg-gray-100 rounded-lg">
                    <!-- TODO MAKE TABS {TESTS & ENDPOINT} -->
                    <h3 class="text-md font-semibold text-gray-600 mb-2">Add New Endpoints</h3>
                    <div class="flex flex-row gap-4">
                        <label for="service" class="block text-xs font-medium leading-6 text-gray-900 w-1/5">
                            Service
                            <select id="service" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2">
                                <option selected="">REFERENCE</option>
                                <option value="TV">RECRUITER</option>
                            </select>
                        </label>

                        <label for="method" class="block text-xs font-medium leading-6 text-gray-900 w-44">
                            Method
                            <select id="method" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2">
                                <option selected="">GET</option>
                                <option value="TV">POST</option>
                                <option value="TV">PATCH</option>
                                <option value="TV">PUT</option>
                                <option value="TV">DELETE</option>
                            </select>
                        </label>

                        <label for="url" class="block text-xs font-medium leading-6 text-gray-900 w-4/6">
                            Path
                            <input type="text" name="path" id="path" autocomplete="path" class="block w-full rounded-md border-0 py-1.5 px-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
                        </label>

                        <button class="flex items-center justify-center rounded-lg bg-gray-200 hover:bg-gray-600 text-black hover:text-white w-16 h-[36px] mt-6">
                            Save
                        </button>
                        <button class="flex items-center justify-center rounded-lg bg-gray-200 hover:bg-gray-600 text-black hover:text-white w-20 h-[36px] mt-6">
                            Delete
                        </button>
                    </div>
                </div>
                <button class="flex items-center bg-blue-600 hover:bg-blue-700 py-2 px-4 gap-2 text-white rounded-lg ml-auto" onclick="updateConfigurationData()">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" />
                    </svg>
                    Add New Endpoints
                </button>
            </div>

            <hr class="hidden nd:block my-16">
        </main>


        <footer class="flex flex-col items-center mx-auto my-16">
            <p id="copyright"></p>
            <div class="flex gap-4 mt-2 text-sm underline underline-offset-8">
                <a href="/metrics" target="_blank" class="hover:decoration-blue-500">METRICS</a>
                <a href="https://github.com/SkilledIn/skilledin-api-gateway" target="_blank" class="hover:decoration-blue-500">GITHUB</a>
                <a href="https://github.com/aasumitro/skilledin-api-gateway/wiki" target="_blank" class="hover:decoration-blue-500">WIKI</a>
            </div>
        </footer>

        <!-- notification banner -->
        <div class="hidden flex flex-col p-8 bg-gray-800 shadow-md hover:shadow-lg rounded-2xl w-[500px] fixed bottom-0 right-0 mb-8 mr-8" id="notify-banner">
            <div class="flex items-center justify-between">
                <div class="flex items-center">
                    <svg xmlns="http://www.w3.org/2000/svg" class="hidden w-16 h-16 rounded-2xl p-3 border border-gray-800 text-blue-400 bg-gray-900" fill="none" viewBox="0 0 24 24" stroke="currentColor" id="notify-info-icon">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                    </svg>
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="hidden w-16 h-16 rounded-2xl p-3 border border-gray-800 text-red-400 bg-gray-900" id="notify-error-icon">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" />
                    </svg>
                    <div class="flex flex-col ml-3 w-fit">
                        <div class="font-medium leading-none text-gray-100" id="notify-title"></div>
                        <p class="text-sm text-gray-400 leading-none mt-1" id="notify-message"></p>
                    </div>
                </div>
            </div>
        </div>

        <script src="./index.js"></script>
    </body>
</html>

@aasumitro
Copy link
Author

package reference_test

import (
"errors"
"net/http/httptest"
"testing"

"github.com/gofiber/fiber/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"skilledin.io/lms/internal/domain/entity"
"skilledin.io/lms/internal/module/reference"
"skilledin.io/lms/mocks"
"skilledin.io/lms/pkg/http/wrapper"

)

func Test_REST_Handler(_ *testing.T) {
app := fiber.New()
reference.NewRESTHandler(app, new(mocks.IReferenceService))
}

func Test_FetchCountry_ShouldSuccess(t *testing.T) {
app := fiber.New()
svcMock := new(mocks.IReferenceService)
svcMock.On("CountryList",
mock.Anything, mock.Anything, mock.Anything, mock.Anything,
).Return(&wrapper.PaginationResponse[entity.Reference]{}, nil).Once()
path := "/api/v1/references/countries"
handler := reference.RESTHandler{Service: svcMock}
app.Get(path, func(ctx *fiber.Ctx) error {
return ctx.Next()
}, handler.FetchCountry)
req := httptest.NewRequest("GET", path, nil)
res, err := app.Test(req)
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, res.StatusCode, fiber.StatusOK)
}
func Test_FetchCountry_ShouldError(t *testing.T) {
app := fiber.New()
svcMock := new(mocks.IReferenceService)
svcMock.On("CountryList",
mock.Anything, mock.Anything, mock.Anything, mock.Anything,
).Return(nil, errors.New("lorem")).Once()
path := "/api/v1/references/countries"
handler := reference.RESTHandler{Service: svcMock}
app.Get(path, func(ctx *fiber.Ctx) error {
return ctx.Next()
}, handler.FetchCountry)
req := httptest.NewRequest("GET", path, nil)
res, err := app.Test(req)
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, res.StatusCode, fiber.StatusBadRequest)
}

func Test_FetchCriticalSkill_ShouldSuccess(t *testing.T) {
app := fiber.New()
svcMock := new(mocks.IReferenceService)
svcMock.On("CriticalSkillList",
mock.Anything, mock.Anything, mock.Anything, mock.Anything,
).Return(&wrapper.PaginationResponse[entity.Reference]{}, nil).Once()
path := "/api/v1/references/critical-skills"
handler := reference.RESTHandler{Service: svcMock}
app.Get(path, func(ctx *fiber.Ctx) error {
return ctx.Next()
}, handler.FetchCriticalSkill)
req := httptest.NewRequest("GET", path, nil)
res, err := app.Test(req)
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, res.StatusCode, fiber.StatusOK)
}
func Test_FetchCriticalSkill_ShouldError(t *testing.T) {
app := fiber.New()
svcMock := new(mocks.IReferenceService)
svcMock.On("CriticalSkillList",
mock.Anything, mock.Anything, mock.Anything, mock.Anything,
).Return(nil, errors.New("lorem")).Once()
path := "/api/v1/references/critical-skills"
handler := reference.RESTHandler{Service: svcMock}
app.Get(path, func(ctx *fiber.Ctx) error {
return ctx.Next()
}, handler.FetchCriticalSkill)
req := httptest.NewRequest("GET", path, nil)
res, err := app.Test(req)
assert.Nil(t, err)
assert.NotNil(t, res)
assert.Equal(t, res.StatusCode, fiber.StatusBadRequest)
}

@aasumitro
Copy link
Author

data, err := cred.GetToken(context.Background(), policy.TokenRequestOptions{
Scopes: []string{"https://graph.microsoft.com/.default"},
})
fmt.Println(data.Token, err)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment