summaryrefslogtreecommitdiff
path: root/spec/factories/error_tracking/error_event.rb
blob: 83f38150b11ef43f314eb7cfd8fb6ef4d99b5350 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# frozen_string_literal: true

FactoryBot.define do
  # There is an issue to rename this class https://gitlab.com/gitlab-org/gitlab/-/issues/323342.
  factory :error_tracking_sentry_error_event, class: 'Gitlab::ErrorTracking::ErrorEvent' do
    issue_id { 'id' }
    date_received { Time.now.iso8601 }
    stack_trace_entries do
      [
        {
          'function' => 'puts',
          'lineNo' => 14,
          'filename' => 'hello_world.rb',
          'context' => [
            [10, "# Ruby example\n"],
            [11, "class HelloWorld\n"],
            [12, "  def self.message\n"],
            [13, "    @name = 'World'\n"],
            [14, "    puts \"Hello \#{@name}\"\n"],
            [15, "  end\n"],
            [16, "end\n"]
          ]
        },
        {
          'function' => 'print',
          'lineNo' => 6,
          'filename' => 'HelloWorld.swift',
          'context' => [
            [1, "// Swift example\n"],
            [2, "struct HelloWorld {\n"],
            [3, "    let name = \"World\"\n"],
            [4, "\n"],
            [5, "    static func message() {\n"],
            [6, "        print(\"Hello, \\(self.name)\")\n"],
            [7, "    }\n"],
            [8, "}\n"]
          ]
        },
        {
          'function' => 'print',
          'lineNo' => 3,
          'filename' => 'hello_world.php',
          'context' => [
            [1, "// PHP/Hack example\n"],
            [2, "<?php\n"],
            [3, "echo 'Hello, World!';\n"]
          ]
        },
        {
          'filename' => 'blank.txt'
        }
      ]
    end

    skip_create
  end

  factory :error_tracking_error_event, class: 'ErrorTracking::ErrorEvent' do
    error factory: :error_tracking_error

    description { 'ActionView::MissingTemplate' }
    environment { 'development' }
    level { 'error' }
    occurred_at { Time.now.iso8601 }
    payload { Gitlab::Json.parse(File.read(Rails.root.join('spec/fixtures/', 'error_tracking/parsed_event.json'))) }

    trait :browser do
      payload { Gitlab::Json.parse(File.read(Rails.root.join('spec/fixtures/', 'error_tracking/browser_event.json'))) }
    end
  end
end