libept
test.h
Go to the documentation of this file.
1 //#include <ept/core/apt.h>
2 #include <ept/config.h>
3 
4 #include <wibble/test.h>
5 
6 #include <apt-pkg/pkgcache.h>
7 #include <apt-pkg/sourcelist.h>
8 #include <apt-pkg/error.h>
9 #include <apt-pkg/policy.h>
10 #include <apt-pkg/cachefile.h>
11 #include <apt-pkg/progress.h>
12 #include <apt-pkg/pkgcachegen.h>
13 #include <apt-pkg/init.h>
14 #include <cstdlib>
15 
16 
17 #ifndef EPT_TEST_H
18 #define EPT_TEST_H
19 
21  //ept::core::AptDatabase db;
23  pkgInitConfig (*_config);
24  _config->Set("Initialized", 1);
25  _config->Set("Dir", TEST_ENV_DIR);
26  _config->Set("Dir::Cache", "cache");
27  _config->Set("Dir::State", "state");
28  _config->Set("Dir::Etc", "etc");
29  _config->Set("Dir::Etc::sourcelist", "sources.list");
30  _config->Set("Dir::State::status", TEST_ENV_DIR "dpkg-status");
31  pkgInitSystem (*_config, _system);
32  }
33 };
34 
37 };
38 
40 {
41  const char* name;
43  std::string old_value;
44 
45  EnvOverride(const char* name, const char* value)
46  : name(name)
47  {
48  const char* old = getenv(name);
49  if (old)
50  {
51  old_value_set = true;
52  old_value = old;
53  } else
54  old_value_set = false;
55  setenv(name, value, 1);
56  }
58  {
59  if (old_value_set)
60  setenv(name, old_value.c_str(), 1);
61  else
62  unsetenv(name);
63  }
64 };
65 
66 #endif
Definition: test.h:20
Definition: test.h:35
AptTestEnvironment()
Definition: test.h:22
Definition: test.h:39
DebtagsTestEnvironment()
Definition: test.h:36
const char * name
Definition: test.h:41
~EnvOverride()
Definition: test.h:57
std::string old_value
Definition: test.h:43
EnvOverride(const char *name, const char *value)
Definition: test.h:45
bool old_value_set
Definition: test.h:42