Class: DatatrueClient::Bridge

Inherits:
Object
  • Object
show all
Defined in:
lib/datatrue_client/bridge.rb

Overview

Abstracts HTTP details of DataTrueClient commands, all methods are synchronous

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Bridge

Returns a new instance of Bridge.



11
12
13
14
15
# File 'lib/datatrue_client/bridge.rb', line 11

def initialize(options={})
  @host = options[:host] || 'datatrue.com'
  @scheme = options[:scheme] || 'https'
  @api_key = options[:api_key]
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



9
10
11
# File 'lib/datatrue_client/bridge.rb', line 9

def host
  @host
end

#schemeObject

Returns the value of attribute scheme.



9
10
11
# File 'lib/datatrue_client/bridge.rb', line 9

def scheme
  @scheme
end

Instance Method Details

#create_test_run(payload) ⇒ Hash

Creates and queues a DataTrue test run

Parameters:

  • payload (Hash)

    payload = {

    test_run: {
      test_class: 'TestScenario',
      test_id: '1',
      email_users: [1, ...]
    },
    variables: {
      name: value,
      ...
    }
    

    }

Returns:

  • (Hash)

    data about created test run, including job_id



31
32
33
# File 'lib/datatrue_client/bridge.rb', line 31

def create_test_run(payload)
  post("test_runs", payload)
end

#test_run_progress(job_id) ⇒ Hash

Queries test run progress

Parameters:

  • job_id (String)

    test run job id

Returns:

  • (Hash)

    data about progress {

    time: 1463359905,
    status: "working",
    uuid: "a1f7868b1db44d38c16585ce37e4ac3f",
    num: 4,
    total: 5,
    progress: {
      percentage: 80,
      tests: [
        {
          id: 1,
          name: "Test name",
          state: "running",
          steps_completed: 4,
          steps: [
            {
              name: "Step name",
              running: false,
              pending: false,
              error: nil,
              tags: [
                { name: "Tag name', enabled: true, valid: true },
                ...
              ]
            },
            ...
          ]
        },
        ...
      ]
    }
    

    }



70
71
72
# File 'lib/datatrue_client/bridge.rb', line 70

def test_run_progress(job_id)
  get("test_runs/progress/#{job_id}")
end