Giter Club home page Giter Club logo

Comments (5)

jgiovaresco avatar jgiovaresco commented on June 17, 2024 3

@barlogy

To mock httpRequest I've just did

helper.registerAllowedMethod(
    method("httpRequest", Map.class),
    { _ -> ["content": "{}"] }
)

It's working but I don't know if there is a better way

from jenkinspipelineunit.

stchar avatar stchar commented on June 17, 2024

is it still actual?

from jenkinspipelineunit.

gene-pavlovsky avatar gene-pavlovsky commented on June 17, 2024

In my test, I needed to mock readJSON. Well, it's not fully a mock, since it does actually parse the JSON.

helper.registerAllowedMethod('readJSON', [Map], { req -> new groovy.json.JsonSlurper().parseText(req.text) })`

from jenkinspipelineunit.

jcrben avatar jcrben commented on June 17, 2024

Can this library provide default mocks? For readJSON something that actually reads JSON like the above would be a nice default. Having mocked out readJSON a few times, I understand that this would be difficult tho - it accepts a path to a file including a relative path and so such a mock needs to have a sense for where its workspace is.

from jenkinspipelineunit.

nre-ableton avatar nre-ableton commented on June 17, 2024

@jcrben This library provides default mocks for all basic pipeline steps (which was finalized in #518). However, as the readJSON step is part of a plugin (pipeline-utility-steps), there is no default mock for it and you must create your own as @gene-pavlovsky detailed above.

Generally speaking, I don't think that this library should provide default mocks for anything other than the basic pipeline steps, or else it'll be a slippery slope and BasePipelineTest will get bloated.

There is one notable exception to this policy, which is for the docker-workflow plugin, because its mocks are somewhat complex and also because it is very widely-used.

from jenkinspipelineunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.