import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js';
import { check } from "k6";

const session = new Httpx({
  //http://192.168.1.220:8000/api/v1/demianhjw/aigic/0129
  //baseURL: 'http://192.168.1.220:8000/api/v1/demianhjw/aigic/0129',
  baseURL: 'http://192.168.1.220:8000',
  //baseURL: 'https://httpbin.test.k6.io',
  timeout: 20000, // 20s timeout.
});

export default  function testSuite() {

    // let body = JSON.stringify({
    //     "model_name": "Realistic_Vision_V1.4",
    //     "model_type": "tex2img",
    //     "desc": {
    //         "prompt": " a small car",
    //         "steps": 20
    //         }
    // });

    //asyncRequest(method, url, [body], [params])

    //var currentTime = new Date();
   // console.log("await beginTime",currentTime);


    //const respPost = await session.asyncPost(`/api/v1/demianhjw/aigic/0129`, {
    const respPost =   session.asyncPost(`/api/v1/demianhjw/aigic/0129`, {
        "model_name": "Realistic_Vision_V1.4",
        "model_type": "tex2img",
        "desc": {
            "prompt": " a small car",
            "steps": 20
            }
    }, { headers:
        { "Content-Type": "application/json",
        "apikey":"6r9aCCENYah5KPARJ4GLFmlOLs0uAEr2",
        "async":"true"}
    });

    //var endTime = new Date();
    //console.log("endTime",endTime);

    //console.log(respPost.body)

    // check(respPost, {
    //     "status is 200": (r) => r.status === 200,
    //    // "is key correct": (r) => j.json.key === "value",
    // });

//   const resp_get = await session.asyncRequest('GET', `/status/200`);
//   const resp_post = await session.asyncRequest('POST', `/status/200`, { key: 'value' });
//   const resp_put = await session.asyncRequest('PUT', `/status/200`, { key: 'value' });
//   const resp_patch = await session.asyncRequest('PATCH', `/status/200`, { key: 'value' });
//   const resp_delete = await session.asyncRequest('DELETE', `/status/200`);

//   // specific methods are also available.
//   const respGet = await session.asyncGet(`/status/200`);
//   const respPost = await session.asyncPost(`/status/200`, { key: 'value' });
//   const respPut = await session.asyncPut(`/status/200`, { key: 'value' });
//   const respPatch = await session.asyncPatch(`/status/200`, { key: 'value' });
//   const respDelete = await session.asyncDelete(`/status/200`);
}