forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[incident-32914] Disable worktree unit tests (DataDog#31641)
- Loading branch information
Showing
1 changed file
with
73 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,104 @@ | ||
import os | ||
import unittest | ||
# TODO(celian): Reintroduce these tests | ||
|
||
from invoke import Context | ||
""" | ||
NOTE: These tests are disabled since they use git commands that are not mocked yet. | ||
This breaks unit tests ran with macos runners. | ||
""" | ||
|
||
from tasks.libs.common.git import get_default_branch | ||
from tasks.libs.common.gomodules import get_default_modules | ||
from tasks.libs.common.worktree import agent_context, init_env, is_worktree | ||
# import os | ||
# import unittest | ||
|
||
# from invoke import Context | ||
|
||
def get_ctx(): | ||
return Context() | ||
# from tasks.libs.common.git import get_default_branch | ||
# from tasks.libs.common.gomodules import get_default_modules | ||
# from tasks.libs.common.worktree import agent_context, init_env, is_worktree | ||
|
||
|
||
class TestWorktree(unittest.TestCase): | ||
def setUp(self): | ||
# Pull only once | ||
init_env(get_ctx(), '6.53.x') | ||
os.environ['AGENT_WORKTREE_NO_PULL'] = '1' | ||
# def get_ctx(): | ||
# return Context() | ||
|
||
def test_context_is_worktree_true(self): | ||
with agent_context(get_ctx(), '6.53.x'): | ||
self.assertTrue(is_worktree()) | ||
|
||
def test_context_is_worktree_false(self): | ||
self.assertFalse(is_worktree()) | ||
# class TestWorktree(unittest.TestCase): | ||
# def setUp(self): | ||
# # Pull only once | ||
# init_env(get_ctx(), '6.53.x') | ||
# os.environ['AGENT_WORKTREE_NO_PULL'] = '1' | ||
|
||
def test_context_nested(self): | ||
with agent_context(get_ctx(), '6.53.x'): | ||
with agent_context(get_ctx(), '6.53.x'): | ||
self.assertTrue(is_worktree()) | ||
self.assertTrue(is_worktree()) | ||
# def test_context_is_worktree_true(self): | ||
# with agent_context(get_ctx(), '6.53.x'): | ||
# self.assertTrue(is_worktree()) | ||
|
||
def test_context_pwd(self): | ||
ctx = get_ctx() | ||
# def test_context_is_worktree_false(self): | ||
# self.assertFalse(is_worktree()) | ||
|
||
with agent_context(ctx, None, skip_checkout=True): | ||
pwdnone = ctx.run('pwd').stdout | ||
# def test_context_nested(self): | ||
# with agent_context(get_ctx(), '6.53.x'): | ||
# with agent_context(get_ctx(), '6.53.x'): | ||
# self.assertTrue(is_worktree()) | ||
# self.assertTrue(is_worktree()) | ||
|
||
with agent_context(ctx, '6.53.x'): | ||
pwd6 = ctx.run('pwd').stdout | ||
# def test_context_pwd(self): | ||
# ctx = get_ctx() | ||
|
||
with agent_context(ctx, 'main'): | ||
pwdmain = ctx.run('pwd').stdout | ||
# with agent_context(ctx, None, skip_checkout=True): | ||
# pwdnone = ctx.run('pwd').stdout | ||
|
||
self.assertEqual(pwd6, pwdnone) | ||
self.assertEqual(pwd6, pwdmain) | ||
# with agent_context(ctx, '6.53.x'): | ||
# pwd6 = ctx.run('pwd').stdout | ||
|
||
def test_context_modules(self): | ||
ctx = get_ctx() | ||
# with agent_context(ctx, 'main'): | ||
# pwdmain = ctx.run('pwd').stdout | ||
|
||
with agent_context(ctx, 'main'): | ||
modules7 = get_default_modules() | ||
# self.assertEqual(pwd6, pwdnone) | ||
# self.assertEqual(pwd6, pwdmain) | ||
|
||
with agent_context(ctx, '6.53.x'): | ||
modules6 = get_default_modules() | ||
# def test_context_modules(self): | ||
# ctx = get_ctx() | ||
|
||
self.assertNotEqual(set(modules6.keys()), set(modules7.keys())) | ||
# with agent_context(ctx, 'main'): | ||
# modules7 = get_default_modules() | ||
|
||
def test_context_branch(self): | ||
ctx = get_ctx() | ||
# with agent_context(ctx, '6.53.x'): | ||
# modules6 = get_default_modules() | ||
|
||
with agent_context(ctx, 'main'): | ||
branch7 = get_default_branch() | ||
# self.assertNotEqual(set(modules6.keys()), set(modules7.keys())) | ||
|
||
with agent_context(ctx, '6.53.x'): | ||
branch6 = get_default_branch() | ||
# def test_context_branch(self): | ||
# ctx = get_ctx() | ||
|
||
self.assertNotEqual(branch6, branch7) | ||
# with agent_context(ctx, 'main'): | ||
# branch7 = get_default_branch() | ||
|
||
def test_context_no_checkout(self): | ||
ctx = get_ctx() | ||
# with agent_context(ctx, '6.53.x'): | ||
# branch6 = get_default_branch() | ||
|
||
with agent_context(ctx, '6.53.x'): | ||
branch6 = get_default_branch() | ||
# self.assertNotEqual(branch6, branch7) | ||
|
||
with agent_context(ctx, 'main'): | ||
branch7 = get_default_branch() | ||
# def test_context_no_checkout(self): | ||
# ctx = get_ctx() | ||
|
||
with agent_context(ctx, 'main', skip_checkout=True): | ||
branch_no_checkout = get_default_branch() | ||
# with agent_context(ctx, '6.53.x'): | ||
# branch6 = get_default_branch() | ||
|
||
self.assertNotEqual(branch6, branch7) | ||
self.assertEqual(branch7, branch_no_checkout) | ||
# with agent_context(ctx, 'main'): | ||
# branch7 = get_default_branch() | ||
|
||
def test_context_no_checkout_error(self): | ||
ctx = get_ctx() | ||
# with agent_context(ctx, 'main', skip_checkout=True): | ||
# branch_no_checkout = get_default_branch() | ||
|
||
with agent_context(ctx, '6.53.x'): | ||
pass | ||
# self.assertNotEqual(branch6, branch7) | ||
# self.assertEqual(branch7, branch_no_checkout) | ||
|
||
def switch_context(): | ||
# The current branch is not main | ||
with agent_context(ctx, 'main', skip_checkout=True): | ||
pass | ||
# def test_context_no_checkout_error(self): | ||
# ctx = get_ctx() | ||
|
||
self.assertRaises(AssertionError, switch_context) | ||
# with agent_context(ctx, '6.53.x'): | ||
# pass | ||
|
||
# def switch_context(): | ||
# # The current branch is not main | ||
# with agent_context(ctx, 'main', skip_checkout=True): | ||
# pass | ||
|
||
# self.assertRaises(AssertionError, switch_context) |